Hello All dev, Here We learn to PHP Hello World With mvc architecture in php example as well as database connection without any framework.
Hello World Example using PHP MVC
i have to create main 2 files in PHP Hello World Example like bellow.
- controller/welcome.php
- views/welcome/index.php

definition of the mvc in php
MODEL:here php model is a class file which contains the Database connectivity queries inside it.
CONTROLLER:This file access the all methods and here easy to define a variables declared.
VIEW:It all the data contains all the html body part and view page like as a listing, form or more.
Also Read: CRUD operation with server side
In php Controller make a file named like as a “welcome.php”. This php file will be saved in the Controller folder.
controller/welcome.php
<?php class Welcome extends Controller { function __construct() { parent::__construct(); } function index() { $this->view->render('welcome/index'); }
and then simple Create a file name main root file like name as a index.php as well as place inside HTML views folder.
views/welcome/index.php
<!DOCTYPE html> <html> <head> <title>Welcome Pakainfo.com</title> </head> <body> <p>Welcome To Pakainfo!!</p> <b>PHP Hello World Example</b> </body> </html>
Last step to you can run the php file in any browser like as a Mozila, Chrome.: http://localhost/mvc/welcome/index
Also Read: PHP OOP CRUD MVC Framework Tutorial
Related FAQ
Here are some more FAQ related to this Article: