What is the difference between $ _SERVER ['PATH_INFO'] and $ _SERVER ['ORIG_PATH_INFO']?

What is the difference between $_SERVER['PATH_INFO'] and $_SERVER['ORIG_PATH_INFO'] ? How to use them?

When I run print_r($_SERVER) , PATH_INFO and ORIG_PATH_INFO not present in the array. Why not? How to enable them?

I read the PHP manual on them, but still don't understand them.

+8
php apache
source share
4 answers

The PATH_INFO variable PATH_INFO present only if you call the PHP script as follows:

 http://www.example.com/phpinfo.php/HELLO_THERE 

This is only the /HELLO_THERE part after the .php script. If you do not call such a URL, there will be no $_SERVER["PATH_INFO"] environment variable.

The PORIG_ prefix PORIG_ somewhat unusual. PATH_INFO is a standard CGI environment variable and should never be prefixed. Where did you read this? (There were some problems around PHP3 / PHP4 if you called the PHP interpreter via cgi-bin / - but hardly anyone has such settings today.)

For reference: http://www.ietf.org/rfc/rfc3875

+14
source share

try the following:

 $path_info = !empty($_SERVER['PATH_INFO']) ? $_SERVER['PATH_INFO'] : (!empty($_SERVER['ORIG_PATH_INFO']) ? $_SERVER['ORIG_PATH_INFO'] : ''); 
+6
source share

Prior to 5.2.4, PATH_INFO apparently corrupted (not installed) in the default configuration. Maybe it is so.

https://bugs.php.net/bug.php?id=31892

The PHP manual says that ORIG_PATH_INFO :

The original version of 'PATH_INFO' before PHP processing.

Reference:
http://php.net/manual/en/reserved.variables.server.php

+2
source share

PATH_INFO and ORIG_PATH_INFO are rarely used. They refer to something in the request path (part of the URL from the first / on) that comes after the file name, and the query string. Typically, you will not have PATH_INFO in the url.

I assume that you mean ORIG_PATH_INFO, not PORIG_PATH_INFO. Path information can be controlled by things like mod_rewrite and PHP scripts. ORIG_PATH_INFO is PATH_INFO, as it was in the original query, before any rewriting or other string manipulation was performed.

+1
source share

All Articles