|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Submitted: 2001-07-22 18:06 UTC Modified: 2001-07-22 21:49 UTC
From: michael at frifra dot de Assigned:
Status: Not a bug Package: Variables related
PHP Version: 4.0.6 OS: WinNT IIS
Private report: No CVE-ID: None
 [2001-07-22 18:06 UTC] michael at frifra dot de

The code is ok and work on several servers, but on my own M$ IIS i get the return Message:

Warning: Undefined variable: SCRIPT_FILENAME in C:\Inetpub\wwwroot\informatik\index.php3 on line 50

Warning: Failed opening '/inc/' for inclusion (include_path='') in C:\Inetpub\wwwroot\informatik\index.php3 on line 51

What could be the reason?


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2001-07-22 18:10 UTC]
This is because microsoft's directory structure uses backslashes
, not forward slashes in your script.  Try replacing the "/" with "\\"

 [2001-07-22 18:18 UTC]
Also, make sure that register_globals is set to on in your
php.ini file.
 [2001-07-22 19:30 UTC] michael at frifra dot de
In my php.ini is:

register_globals = ON

if i declare
global $SCRIPT_FILENAME -> i get an empty string! On all other servers i can run my script, only on my own... why?
 [2001-07-22 19:34 UTC]
instead of $SCRIPT_FILENAME.
 [2001-07-22 19:42 UTC] michael at frifra dot de
If i use this code:

the variable $path is empty, because $SCRIPT_FILENAME is empty!

if a type in the complete path as static variable, it works... but i have to use dirname($SCRIPT_FILENAME) for the possibility to run that script on other servers.

 [2001-07-22 19:49 UTC]
Please replace $SCRIPT_FILENAME with

so $path=dirname($SCRIPT_FILENAME);

would be changed to


Please tell me if this works.

Status -> Feedback
Type -> Variables related
 [2001-07-22 19:52 UTC]

this is bogus.
 [2001-07-22 19:53 UTC] michael at frifra dot de
If i use:

i get:
Warning: Undefined index: SCRIPT_FILENAME 
 [2001-07-22 19:56 UTC]
Sorry about that...


if that doesn't work, I am stumped.

--By the way, get Linux.

 [2001-07-22 20:08 UTC] michael at frifra dot de
If i replace $SCRIPT_FILENAME with $HTTP_SERVER_VARS["SCRIPT_NAME"] the dirname function only returns the path from the inet_root but not from the harddrive root.

if i type in the whole path manualy and the inclusion woks, i see that


is also empty... so my whole project could not work at my server...

I think its a general configuration problem, but what sholud i do?

"--By the way, get Linux." -> later... i have no experience with Linux
 [2001-07-22 20:10 UTC]

I can't help you anymore.  This is totally bogus.

The linux thing was a joke, because nothing like this would happen with linux.

 [2001-07-22 20:19 UTC]
Michael, I think you should devote some time to read the PHP documentation. You're trying to make orange juice from apples. That won't work.

Also, next time you think you've found a bug, please check that it's not a PEBKAC.

Last, give only accurate, and TRUE!!! info in bug reports. I could easily see that your bug report was bogus, but with something more complicated or subtle, your claim that it works on other machines could mislead a developer, and cost them a lot of their time. I'm sure that would not be your goal.

Andi, I didn't get your remark about Linux. The behavior he was seeing is completely platform independent.
 [2001-07-22 20:21 UTC]
Ouch Andy, that seemed pretty harsh.

Anyways,  do you have a page up I can look at with phpinfo() in it?  If not just make a quick page like so


 [2001-07-22 20:26 UTC]

Sorry about my remark.

If you create a page like cnewbill said, you can see all of environmental
variables, server variables, etc... that PHP defines.

Also, as cynic said check out the documentation at

Hopefully you can get it to work...
 [2001-07-22 20:30 UTC]
One last remark before I definitely leave this PR:
Michael, you might also want to subscribe to php-general@,
that can be done by sending an empty email to
 [2001-07-22 20:35 UTC]
make sure you have a big mailbox if you subscribe to this mailing list.

You get lots of messages...
 [2001-07-22 21:24 UTC] michael at frifra dot de

i just made a page with




 [2001-07-22 21:35 UTC]
I'm assuming you want to be able to call these includes, and you think you need to know the path?

IMO, there is a much cleaner way that you can use regardless of your current working directory.

Create a directory where all your scripts will go, for example C:\Inetpub\php\.  Modify your include_path to include our new directory C:\Inetpub\php.  Move your "inc/" directory to this new directory.

Now your code can be
no matter what directory you are in.  You just need to make sure you have your path setup in the order you want it processed in, otherwise if you have an inc/ in your current working dir it will use that one first.  Which is also good in some cases.

I've honestly never used $SCRIPT_FILENAME, I've always used $PHP_SELF or one of the HTTP_SERVER_VARS.

 [2001-07-22 21:49 UTC]
Please, take this where it belongs:
 [2002-10-30 10:59 UTC] php-bugs at b-a-l-u dot de
This is more than a year old, but I think I might add this thought, because I struggled over a similar problem and found this bug with no real result - perhaps it helps others that search for a problem like this.

SCRIPT_FILENAME is an Apache Environment-Variable (at least phpinfo() lists it there. And it does not exist on IIS-systems.

SCRIPT_NAME seems to be known by both systems. (There are / were other bugs with PHP-Versions that have the path to php.exe in it.

PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Jul 21 10:01:30 2024 UTC