I need to get the path from the URL of the current request. For example, if the current URL is:
"http://www.example.com/example/test/hi.php?randomvariable=1"
I would want this:
"/example/test/hi.php?randomvariable=1"
I need to get the path from the URL of the current request. For example, if the current URL is:
"http://www.example.com/example/test/hi.php?randomvariable=1"
I would want this:
"/example/test/hi.php?randomvariable=1"
You want
$_SERVER['REQUEST_URI']
. From the docs:$_SERVER['REQUEST_URI']
will give you the path after the domain name. In your example "/example/test/hi.php?randomvariable=1"it should be :
Take a look at : Get the full URL in PHP