A super-simple way to implement pseudo-URLs under PHP [Go]_php tutorial

Source: Internet
Author: User
Just like the address path in my log, let Index.php?action=one&do=two
Become:? index/action/one/do/two
Copy CodeThe code is as follows:
index.php
--------------

Parsing QUERY STRING
$QS =explode ("&", $_server[' query_string ']);
$QS =explode ('/', $QS [0]);

IF Modul is Undefined set it to index
if (! $QS [0]) $MODUL = ' index ';
else $MODUL =strtolower ($QS [0]);

WE can make a Variable $_query
For alternative _get
for ($i =1; $i {
$_query[$NVAR]= $NVAR = $QS [$i];
$ $NVAR = $QS [$i +1];
}

Check The Modul is exists?
if (!file_exists ("modul_directory/{$MODUL}.php"))
$MODUL = "index";

# # # # # # # # # EXAMPLE to implementation the SCRIPT
Load the Template
Include ("template.php");
Load the Module
Include ("modul_directory/{$MODUL}.php");
Load the Footer
Include ("footer.php");

?>

We can access the Modul in URL like this:
=================================

Www.example.com/?forum/topic/20
-it mean load the Modul forum.php, and set the _query[' topic ']=20

www.foo.com/?voting/id/54/type/piechart&choice=2
-it mean load the Modul voting.php, and set the _query[' ID ']=54 and _query[' type ']= ' Piechart ' and set _get[' Choice ']=2

http://www.bkjia.com/PHPjc/318416.html www.bkjia.com true http://www.bkjia.com/PHPjc/318416.html techarticle just like the address path in my log, let index.php?action=onenbsp; index/action/one/do/two copy the Code code as follows: index.php--------------? PHP// Parsingquerystring ...

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.