Monday, March 31, 2014

PHP FRONT CONTROLLER BASIC CONCEPT

-----
FRONT CONTROLLER BASIC CONCEPT

STEPS

1) Create Directory Structure.

[webroot]\frontcontroller1\
----------index.php
----------pages\
--------------------home.php
--------------------account.php

2) Codes

2.1) index.php

<?php
  session_start();
  $redirect = !empty($_GET["page"])? $_GET["page"] : "home";
  switch($redirect){
   case "home":
      include "pages/home.php";
      break;
   case "account":
      include "pages/account.php";
      break;    
  }
?>
2.2) home.php

<?php
echo "this is home";
?>
2.3) account.php

<?php
echo "this is account";
?>

No comments:

Post a Comment

Labels