.


Divya

Hello World Example using PHP MVC


MODEL:It is a class file which contains the Database connectivity queries inside it.

CONTROLLER:This file access the methods and variables declared.

VIEW:It contains all the html and view page.

In Controller create a file named "hello.php". This file will be saved in the Controller folder.

controller/hello.php

<?php

class Hello extends Controller {

	function __construct() {
		parent::__construct();
	}
	
	function index() {
	
		
		$this->view->render('hello/index');
		
	}

Create a file index.php and place inside views folder.

views/hello/index.php

<!DOCTYPE html>  
<html>  
<head>  
    <title>Hello World</title>  
</head>  
<body>  
  
 <p>Hello World!!</p>  
 </body>  
</html>  

Now run the file in any browser: http://localhost/mvc/hello/index



.