Model View Controller(MVC) in PHP Hello World Example

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.

Read Also:  Laravel 6 Update Increment column

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.

Read Also:  PHP Convert stdclass object recursive


class Welcome extends Controller {

	function __construct() {
	function 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.


<!DOCTYPE html>  
 <p>Welcome To Pakainfo!!</p>  
 <b>PHP Hello World Example</b>

Last step to you can run the php file in any browser like as a Mozila, Chrome.: http://localhost/mvc/welcome/index

Read Also:  Check if row exists using Laravel

Also Read: PHP OOP CRUD MVC Framework Tutorial

About Pakainfo

I am Jaydeep Gondaliya, a software engineer, the founder and the person running Pakainfo. I'm a full-stack developer, entrepreneur and owner of I live in India and I love to write tutorials and tips that can help to other artisan, a Passionate Blogger, who love to share the informative content on PHP, Javascript, JQuery, Laravel, Codeigniter, VueJS, AngularJS and Bootstrap from the early stage.

View all posts by Pakainfo →

Leave a Reply

Your email address will not be published. Required fields are marked *