php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #25448 $_SERVER['PHP_SELF'] fails to return a value (broken since 4.3.2)
Submitted: 2003-09-09 06:59 UTC Modified: 2004-08-07 19:09 UTC
Votes:5
Avg. Score:4.6 ± 0.8
Reproduced:4 of 4 (100.0%)
Same Version:2 (50.0%)
Same OS:3 (75.0%)
From: david at advisorymatters dot co dot uk Assigned:
Status: Closed Package: Documentation problem
PHP Version: 4.3.3 OS: win32
Private report: No CVE-ID: None
 [2003-09-09 06:59 UTC] david at advisorymatters dot co dot uk
Description:
------------
Running the code (below) on 4.3.2 and above (I've checked it on 4.3.2, 4.3.3RC1 to RC4 and 4.3.3) fails to produce any output. On 4.3.0 and 4.3.1 it works fine.

For testing I am changing over the PHP versions just by renaming the c:\php dir (from c:\php431, c:\php432, c:\php433-1 etc). Nothing in the application changes and I am using one common php.ini file for all php versions, ONLY the php version itself is changed. All PHP versions are the standard Win32 Binaries with no modifications.

In php.ini register globals are OFF and the only other changes are to turn a few extensions on (GD and DBX).

I am using the Xitami web server version 2.4d9 from http://www.xitami.com on a Compaq Evo system (Celeron 1.8MHz, 128MB RAM, WinXPPro).

I've noticed that this (or similar) bugs have been reported recently (e.g. #24979) but dismissed by stating that it works with the latest CVS etc. If this is the case when this bug report is checked then I would suggest that there is something else going on here that is not showing up on your test systems. It is ALWAYS reproducible here. Note that using $_SERVER['SCRIPT_NAME'] DOES work (but my code tends to use $_SERVER['PHP_SELF'] and why should I change?).



Reproduce code:
---------------
<?php
print "self = " . $_SERVER['PHP_SELF'];
?>

Expected result:
----------------
With the above code in the file test.php in the web server's document root:

self = /test.php


Actual result:
--------------
self = 


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-09-11 21:11 UTC] sniper@php.net
Set this in your php.ini and this will work:
cgi.fix_pathinfo=1

This setting defaults to 0 for some backwards compatibility
reasons with some other web servers.

Should be documented on the Xitami install page (and maybe the cgi page?)

 [2003-09-12 04:56 UTC] david at advisorymatters dot co dot uk
Yes, thanks sniper, That fixed it (and apologies for being rather short in one of my earlier (now deleted) replies - I was having a bad day!) I have added a short note to the PHP/Xitami docs page about this requirement.
 [2003-11-03 05:05 UTC] phildriscoll@php.net
The windows installer distribution for php 4.3.4 has been 
changed to set cgi.fix_pathinfo=1 when intalling for 
Xitami web servers.  
 [2004-08-07 19:09 UTC] vrana@php.net
This bug has been fixed in the documentation's XML sources. Since the
online and downloadable versions of the documentation need some time
to get updated, we would like to ask you to be a bit patient.

Thank you for the report, and for helping us make our documentation better.

"If you want use $_SERVER['PHP_SELF'] you have to enable cgi.fix_pathinfo directive."
 [2004-08-22 06:46 UTC] renegaderesearch at hotpop dot com
Directed to comment here from bug #25450:

I'm using PHP 3.4.8 on Apache(Module not cgi) on Windows 98 SE. $_SERVER['PHP_SELF'] = /index.php

Reproduce code:
---------------
echo dirname($_SERVER['PHP_SELF']);

Expected result:
----------------
/

Actual result:
--------------
\
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 16:01:28 2024 UTC