php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #26429 Documentation for $_SERVER["SCRIPT_FILENAME"] incorrect
Submitted: 2003-11-26 23:50 UTC Modified: 2004-01-01 17:57 UTC
From: skissane at ics dot mq dot edu dot au Assigned: kennyt (profile)
Status: Closed Package: Documentation problem
PHP Version: 4.3.4 OS: Linux
Private report: No CVE-ID: None
 [2003-11-26 23:50 UTC] skissane at ics dot mq dot edu dot au
Description:
------------
According to the documentation:
'SCRIPT_FILENAME'
The absolute pathname of the currently executing script. 

But, when I do 'echo $_SERVER["SCRIPT_FILENAME"]', using PHP-CLI, I get a pathname relative to the current directory.

So either the docs are wrong, or the code is buggy (suggest that documented behaviour is more useful than actual behaviour, hence code should be changed.)

(Despite what the form forced me to say above, I'm actually using 4.3.4RC1, not 4.3.4, but I hope it makes no difference. Apologies if it does.)

Reproduce code:
---------------
Make a directory called foo, under $HOME.
Put this file as test.php in $HOME:
<?
echo $_SERVER["SCRIPT_FILENAME"] . "\n";
Now cd to $HOME
Execute: php foo/test.php


Expected result:
----------------
<path to your home directory>/foo/test.php

Actual result:
--------------
foo/test.php

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-11-26 23:55 UTC] rasmus@php.net
The docs should be modified to reflect the fact that all server variables except PHP_SELF, argc and argv are set by the web server and PHP has absolutely no control over their values.  While Apache sets them to one thing, another server may set them to another, and there may be differences between the server module version and the CGI interface to any of these web servers.
 [2003-11-27 01:48 UTC] skissane at ics dot mq dot edu dot au
rasmus wrote:
"The docs should be modified to reflect the fact that all server variables except PHP_SELF, argc and argv are set by the web server and PHP has absolutely no control over their values"

Not true -- As I said, I am using PHP-CLI. No webserver involved at all. Of course PHP has control over them all when running using the CLI sapi (excluding of course any brought in from the environment...)
 [2003-12-15 14:58 UTC] dave@php.net
Rasmus: The documentation already states that you can't trust the $_SERVER values: "There is no guarantee that every webserver will provide any of these; servers may omit some, or provide others not listed here."

However, skissane is correct. SCRIPT_FILENAME does return the relative path in the CLI version. The question is, should the code be fixed to make it absolute, or should the documentation have a note appended saying that it's not absolute in the CLI version?
 [2004-01-01 17:39 UTC] kennyt@php.net
I've written a note to tag under the element's 
description. Waiting for the manual to build now... (Is 
there a way to rebuild just one page? :)
 [2004-01-01 17:46 UTC] derick@php.net
Is it fixed in CVS or not? If it is -> Close the bug. And no you can't build one page in the manual (nor do we want to do that as it's too much work for every little change)
 [2004-01-01 17:57 UTC] kennyt@php.net
Noted the case.

I was waiting for my test copy (http://php.kennyt.com/
manual) to build. That's what the question was about. 
:)
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Sep 18 23:01:26 2024 UTC