Tuesday, August 26, 2014

"HelloWorld" program in PHP CodeIgniter using Netbeans.

   No comments     
categories: 

"HelloWorld" program in PHP CodeIgniter using Netbeans.

Step 1:- download the CodeIgniter framework form the following link “http://ellislab.com/codeigniter/download”.
 

and extract it into “C:/xampp/htdocs/” rename the folder as "codeignter". open a browser and type "http://localhost/codeigniter", you will get following.
s
Step 2:- open netbeans , select 'new project' . in the new project window select 'PHP' and 'PHP Application with Existing Sources'.
then click next
new
type your 'Source folder' and 'project name' in the shown space.
 2
Step 3:-
Create a file at application/controllers/pages.php with the following code.
<?php
class Pages extends CI_Controller {
    public function view($page = 'home')
    {     
    if ( ! file_exists(APPPATH.'/views/pages/'.$page.'.php'))
    {
        // Whoops, we don't have a page for that!
        show_404();
    }
    $data['title'] = ucfirst($page); // Capitalize the first letter

    $this->load->view('templates/header', $data);
    $this->load->view('pages/'.$page, $data);
    $this->load->view('templates/footer', $data);
}  
}
?>
Step 4:-
Create a folder at application/views/templates
Create the header at application/views/templates/header.php and add the following code.
<html>
<head>
    <title><?php echo $title ?> - CodeIgnite</title>
</head>
<body>
    <h1>CodeIgniter 2 Tutorial</h1>
Create the footer at application/views/templates/footer.php and add the following code.
<strong>&copy; 2011</strong>
<script type="text/javascript">if(!NREUMQ.f){NREUMQ.f=function(){NREUMQ.push(["load",new Date().getTime()]);var e=document.createElement("script");e.type="text/javascript";e.src=(("http:"===document.location.protocol)?"http:":"https:")+"//"+"js-agent.newrelic.com/nr-100.js";document.body.appendChild(e);if(NREUMQ.a)NREUMQ.a();};NREUMQ.a=window.onload;window.onload=NREUMQ.f;};NREUMQ.push(["nrfj","beacon-5.newrelic.com","eb488e72a1","3758250","NgEEZBYHDUFWVk0KWg9LJUUXEgxfGFZWB1AIAwhZEAMRHR0=",0,117,new Date().getTime(),"","742446fde086bef8","","",""]);</script></body>
</html>
Step 5:-
In that directory, create two files named home.php and about.php. Within those files, type some text and save them. try "Hello World!".
Open the routing file located at application/config/routes.php and add the following two lines
3
Open the config file located at application/config/config.php and change the following line as shown below
h
Step 6 :- run the project by pressing F6 on your keyboard or as the following button.
ff
get your "hello World"
tt

0 comments:

Post a Comment