Skip to content

Instantly share code, notes, and snippets.

@otar
Created June 18, 2013 14:37
Show Gist options
  • Save otar/5805891 to your computer and use it in GitHub Desktop.
Save otar/5805891 to your computer and use it in GitHub Desktop.
<?php
function request_path()
{
$request_uri = explode('/', trim($_SERVER['REQUEST_URI'], '/'));
$script_name = explode('/', trim($_SERVER['SCRIPT_NAME'], '/'));
$parts = array_diff_assoc($request_uri, $script_name);
if (empty($parts))
{
return '/';
}
$path = implode('/', $parts);
if (($position = strpos($path, '?')) !== FALSE)
{
$path = substr($path, 0, $position);
}
return $path;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment