<?php
/**
*
* @project Framework
*
* @author Harsha M V
* @copyright 2008
*
*/
//print_r($scriptName);
class url_interpreter
{
public $id;
public $module;
public $action;
public $mobile;
public $path;
function __constructor()
{
// Exploding the Components of the Request URL and making an Array of the Components
$requestURI = explode('/', $_SERVER['REQUEST_URI']);
// Exploding the Components of the Script (index.php) and making an Array of the Components
$scriptName = explode('/', $_SERVER['SCRIPT_NAME']);
// Unsetting Array the matches after Matching Script and URL Array
for ($i = 0; $i < sizeof($scriptName); $i++) {
// Matching Array Components
if ($requestURI[$i] == $scriptName[$i]) {
// Unsetting Array if theres a Match
unset($requestURI[$i]);
}
}
// Reseting Array Keys
$path = array_values($requestURI);
//print_r($this->$path);
return $path;
}
}
$hd = new url_interpreter;
print_r($hd);
?>
OUTPUT
url_interpreter Object
(
[id] =>
[module] =>
[action] =>
[mobile] =>
[path] =>
)
When i go to localhost/users/show/11/mobile
it should show
url_interpreter Object
(
[id] => 11
[module] => users
[action] => show
[mobile] => 1
[path] =>
)
how to make the variables
mobule, action and id be available globally. Am getting Confused with the Variable scope. I tried going thru a tutorial also...:mad: