If you want the equivalent of PATH_INFO
to get the path of path , the solution is:
$_SERVER["PHP_SELF"]
The PATH_INFO
only brings the path , without query string and other information, then PHP_SELF
is the nearest substitute.
Understanding the reason
PATH_INFO
is not a PHP variable, it's an Apache variable that is passed to PHP (more accurately, it's a CGI specification, but Apache passes even when PHP is installed as a module). So, it's neither portable, and depends on some conditions even in Apache.
Basically it is used when you have a path that goes beyond the file being accessed, be it a /meu.php/caminho
, or a /caminho/completo
that is being supplied by a PHP file indicated in .htaccess
, route or even as document root (instead of root folder).
While PHP_SELF
is an indication of the script itself being executed, then in your case it will reflect the path that triggered the PHP itself in use. It is important to understand the difference in order to choose which to use in situations where the results of the two values are different.
More details here:
link
link