|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #14295 Scope of globals has changed
Submitted: 2001-11-30 03:51 UTC Modified: 2001-12-31 19:41 UTC
From: v dot puttrich at digitalliquid dot de Assigned:
Status: Not a bug Package: Variables related
PHP Version: 4.0.6 OS: Win2k
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: v dot puttrich at digitalliquid dot de
New email:
PHP Version: OS:


 [2001-11-30 03:51 UTC] v dot puttrich at digitalliquid dot de
The following bug or feature (not yet sure what it is ;)) is related to the scope of global variables.

I use PHP 4.0.6 on Win2k pro as i downloaded it from this web site. 
The loading of extra modules does not change the described behaviour.
The Server API is Apache (Apache V. 1.3.22 win)

register_globals and register_argc_argv is ON

I have the global variable $PHP_SELF.
Now i include a file where I want to use $PHP_SELF.
Within the included file, $PHP_SELF is unknown (it has lost it's global state), and i have to declare it global again.
This appears for any other global variables too, $PHP_SELF is just an example-
This behaviour seems to be new to PHP 4.0.6, because i didn't have the problem with 4.0.5.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2001-11-30 12:25 UTC]
Please include short example scripts here.

 [2001-11-30 15:07 UTC] v dot puttrich at digitalliquid dot de
// Main script

// The global variables are available in this script


// End main script
// File:

// The global variables from the main script are not available here

<form action="<?php echo $PHP_SELF; ?>" method="post">
// End file:

 [2001-12-02 01:52 UTC]
Cannot reproduce under PHP 4.1.0 w/ Linux

Please try the code below. Save the files under the names 
indicated in the comments and try running test.php:

# test.php
<?php include ''; echo "Main File: $PHP_SELF" ?>

<?php echo "Included File: $PHP_SELF" ?>

 [2001-12-04 19:34 UTC]
I can not reproduce this with PHP 4.1.0RC5 either.

 [2001-12-05 01:49 UTC] v dot puttrich at digitalliquid dot de
Zak: I did try it and could reproduce with your code.

I found out, that it only happens when i'm running my scripts on Win2k. On Linux my scripts are running as expected and I don't need to declare $PHP_SELF global again.

The only difference in my PHP configuration is:
On Win2k virtual dirs is enabled, on Linux it's disabled.

Well, I don't know where to set virtual directory support on/off, so I can't verify.
 [2001-12-06 07:41 UTC]
Thanks for trying the scripts! If we are lucky, this bug 
report will help us find what weird thing makes $PHP_SELF 
behave strangely under Win32.

Could you please try the same test with a different global 

 [2001-12-06 08:40 UTC] v dot puttrich at digitalliquid dot de
I have set up a webserver and ftp for you to do the tests you need. The account is running on the system which produces the problem. Feel free to use it as you like.

The server might be offline for a short while sometimes. This is because of redialing and submitting a new IP to every 24 hours.
Additionally the server will be down on Sunday, 12/9/01 00:00:00 Am to 10:00:00 Am european time.

If you should have additional questions or wishes related to the account do not hesitate to ask me.

The password for the FTP will reach you by email.

 [2001-12-06 08:46 UTC] v dot puttrich at digitalliquid dot de
Forgot to say this: Please let me know if you find the problem ; )
 [2001-12-06 08:51 UTC] v dot puttrich at digitalliquid dot de
I'm unable to reach you at ""!
Where should I send the password to?
 [2001-12-31 19:18 UTC]
I should really get around to examining this. :)

 [2001-12-31 19:41 UTC]
Hi Volker,

Thanks for setting up the web server for me. It made 
testing a lot faster.

Thankfully, I could not reproduce the problem on your web 
server. Flagging bug as bogus.

For proof of bogosity, see :

Also, here is a diff out the output of calling v2.php 
directly and calling it via an include call in v1.php

None of the globals are missing in either case. 
Additionally, the two are almost the same -- except for 
the differences noted below.

--- v1.php	Mon Dec 31 17:35:12 2001
+++ v2.php	Mon Dec 31 17:35:02 2001
@@ -1,5 +1,5 @@
-PHP_SELF: /v1.php
+PHP_SELF: /v2.php
 <hr><b>ALLUSERSPROFILE:</b> string(42) "C:\\Dokumente und 
Einstellungen\\All Users"
 <hr><b>CommonProgramFiles:</b> string(33) 
"C:\\Programme\\Gemeinsame Dateien"
@@ -36,8 +36,8 @@
 <hr><b>HTTP_X_FORWARDED_FOR:</b> string(13) 
 <hr><b>PATH:</b> string(55) 
 <hr><b>REMOTE_ADDR:</b> string(13) ""
-<hr><b>REMOTE_PORT:</b> string(5) "51995"
-<hr><b>SCRIPT_FILENAME:</b> string(27) 
+<hr><b>REMOTE_PORT:</b> string(5) "51252"
+<hr><b>SCRIPT_FILENAME:</b> string(27) 
 <hr><b>SERVER_ADDR:</b> string(14) ""
 <hr><b>SERVER_ADMIN:</b> string(11) ""
 <hr><b>SERVER_NAME:</b> string(17) ""
@@ -50,10 +50,10 @@
 <hr><b>SERVER_PROTOCOL:</b> string(8) "HTTP/1.0"
 <hr><b>REQUEST_METHOD:</b> string(3) "GET"
 <hr><b>QUERY_STRING:</b> string(0) ""
-<hr><b>REQUEST_URI:</b> string(7) "/v1.php"
-<hr><b>SCRIPT_NAME:</b> string(7) "/v1.php"
-<hr><b>PATH_TRANSLATED:</b> string(27) 
-<hr><b>PHP_SELF:</b> string(7) "/v1.php"
+<hr><b>REQUEST_URI:</b> string(7) "/v2.php"
+<hr><b>SCRIPT_NAME:</b> string(7) "/v2.php"
+<hr><b>PATH_TRANSLATED:</b> string(27) 
+<hr><b>PHP_SELF:</b> string(7) "/v2.php"
 <hr><b>argv:</b> array(0) {
 <hr><b>argc:</b> int(0)
@@ -95,9 +95,9 @@
   string(13) ""
-  string(5) "51995"
+  string(5) "51252"
-  string(27) "d:/www/phpnet/htdocs/v1.php"
+  string(27) "d:/www/phpnet/htdocs/v2.php"
   string(14) ""
@@ -124,13 +124,13 @@
   string(0) ""
-  string(7) "/v1.php"
+  string(7) "/v2.php"
-  string(7) "/v1.php"
+  string(7) "/v2.php"
-  string(27) "d:/www/phpnet/htdocs/v1.php"
+  string(27) "d:/www/phpnet/htdocs/v2.php"
-  string(7) "/v1.php"
+  string(7) "/v2.php"
   array(0) {

PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Jul 13 08:01:29 2024 UTC