localhost上的$ _SERVER ['PATH_INFO']

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?

If your url looks like this http://localhost/ then $_SERVER['PATH_INFO'] is not set.

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: localhost/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: localhost/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