$PHP_SELF contains strange data

I think there is an issue with PHP5.3 in cgi mode. I tried this under Debian Lenny and Ubuntu Lucid:

  1. Fresh install of Ubuntu / Debian with Virtualmin PHP Running in cgi mode
  2. php File with print_r( $PHP_SELF) and print_r($_SERVER['PHP_SELF']);
  3. The output is: /cgi-bin/php5.cgi but should be test.php

Maybe there is an issue with your php5.cgi script under cgi-bin? Please take a look at it.

BTW: I found this issue while debugging wordpress, which is not running under PHP5.3 in cgi mode. in fcgi mode it works fine.



Howdy -- that's correct, that's the normal PHP behavior when running in CGI mode. There's a lot of other folks unhappy about that behavior in PHP when Googling about that issue :-)

You should be able to work around that issue by editing your Virtual Server's php.ini file in $HOME/etc/php.ini, and to set this parameter:


With that option set on a Debian 6 test system I have here, the PHP_SELF parameter is set as you're looking for.