Just like the address path in my log, let index. php? Action = one & do = two
Changed :? Index/action/one/do/two
Copy codeThe Code is as follows:
Index. php
--------------
<? 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 <count ($ QS); $ I + = 2)
{
$ _ QUERY [$ NVAR] = $ NVAR = $ QS [$ I];
$ NVAR = $ QS [$ I + 1];
}
// Check the Modul is exists?
If (! File_exists ("modul_directory/{$ MODUL}. php "))
$ MODUL = "index ";
#### THIS IS 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'] = 'piechar' and set _ GET ['choice'] = 2