Skip to content

k4ng/simple-routing-with-php

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Simple Routing With PHP

An example how to make a routing URL in PHP Language

Instalation

  • Clone this repo git clone https://github.com/k4ng/simple-rooting-with-php.git
  • Move to htdocs
  • Open index.php
  • Change path project dir /x-kang/simple-routing-with-php in variable $project_location
  • Done, You can try to access in your browser now :)

Sample Pages

  • Home Page localhost/PROJECT_DIR/
  • About Page localhost/PROJECT_DIR/about
  • Contact Page localhost/PROJECT_DIR/contact

Add And Remove PAGE

If you want to add or remove page you can added new CASE in this part code in index.php

switch ($request) {
    case $me.'/' :
        require "views/home.php";
        break;
    case $me.'/about' :
        require "views/about.php";
        break;
    case $me.'/contact' :
        require "views/contact.php";
        break;
    default:
        http_response_code(404);
        echo "404";
        break;
}

Author

kang-cahya.com

Source License

MIT License