Reputation: 6389
I'm getting the following error when I use $_SERVER['PATH_INFO']
on my localhost:
Notice: Undefined index: PATH_INFO
I'm using WAMP. Can someone tell me why this is happening?
Upvotes: 5
Views: 18875
Reputation: 3023
PATH_INFO
isn't always set. It is only set if there was trailing path info after the script.
For example if you have a file located here: localhost/index.php
and you access it via this URL: http://localhost:8000/index.php/foo/bar
then $_SERVER['PATH_INFO']
will be set to a value of "/foo/bar"
but if you access the script via the URL: http://localhost:8000/index.php then PATH_INFO
will not be set and you will see a notice like that for attempting to access an undefined index of an array.
Upvotes: 23
Reputation: 9581
According to documentation: PHP Manual - $_SERVER .
There is no guarantee that every web server will provide any of these; servers may omit some, or provide others not listed here.
That has been said, try
$_SERVER['REQUEST_URI'];
Upvotes: 1
Reputation: 146310
If your url looks like this
http://localhost/
then $_SERVER['PATH_INFO']
is not set.
Upvotes: 4