php.net |  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
 [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.

SYSTEM:
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)

PHP.INI:
register_globals and register_argc_argv is ON


DESCRIPTION:
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.

Patches

Pull Requests

History

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

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

// The global variables are available in this script

include("form.inc.php");

  ...
// End main script
----
// File: form.inc.php

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

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

 [2001-12-02 01:52 UTC] zak@php.net
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 'test.inc'; echo "Main File: $PHP_SELF" ?>

# test.inc
<?php echo "Included File: $PHP_SELF" ?>






 [2001-12-04 19:34 UTC] sniper@php.net
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] zak@php.net
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 
value?

 [2001-12-06 08:40 UTC] v dot puttrich at digitalliquid dot de
zak:
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.

NOTE: 
The server might be offline for a short while sometimes. This is because of redialing and submitting a new IP to DynDNS.org 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.

HTTP and FTP: phpnet.homeip.net
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 "zak@php.net"!
Where should I send the password to?
 [2001-12-31 19:18 UTC] zak@php.net
I should really get around to examining this. :)

 [2001-12-31 19:41 UTC] zak@php.net
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 :
  http://phpnet.homeip.net/v1.php
  http://phpnet.homeip.net/v2.php

  http://phpnet.homeip.net/v1.phps
  http://phpnet.homeip.net/v2.phps

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 @@
 <pre>
-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) 
"207.34.113.45"
 <hr><b>PATH:</b> string(55) 
"C:\\WINNT\\system32;C:\\WINNT;C:\\WINNT\\System32\\Wbem"
 <hr><b>REMOTE_ADDR:</b> string(13) "207.34.94.239"
-<hr><b>REMOTE_PORT:</b> string(5) "51995"
-<hr><b>SCRIPT_FILENAME:</b> string(27) 
"d:/www/phpnet/htdocs/v1.php"
+<hr><b>REMOTE_PORT:</b> string(5) "51252"
+<hr><b>SCRIPT_FILENAME:</b> string(27) 
"d:/www/phpnet/htdocs/v2.php"
 <hr><b>SERVER_ADDR:</b> string(14) "217.224.230.39"
 <hr><b>SERVER_ADMIN:</b> string(11) "zak@php.net"
 <hr><b>SERVER_NAME:</b> string(17) "phpnet.homeip.net"
@@ -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) 
"d:/www/phpnet/htdocs/v1.php"
-<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) 
"d:/www/phpnet/htdocs/v2.php"
+<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 @@
   ["REMOTE_ADDR"]=>
   string(13) "207.34.94.239"
   ["REMOTE_PORT"]=>
-  string(5) "51995"
+  string(5) "51252"
   ["SCRIPT_FILENAME"]=>
-  string(27) "d:/www/phpnet/htdocs/v1.php"
+  string(27) "d:/www/phpnet/htdocs/v2.php"
   ["SERVER_ADDR"]=>
   string(14) "217.224.230.39"
   ["SERVER_ADMIN"]=>
@@ -124,13 +124,13 @@
   ["QUERY_STRING"]=>
   string(0) ""
   ["REQUEST_URI"]=>
-  string(7) "/v1.php"
+  string(7) "/v2.php"
   ["SCRIPT_NAME"]=>
-  string(7) "/v1.php"
+  string(7) "/v2.php"
   ["PATH_TRANSLATED"]=>
-  string(27) "d:/www/phpnet/htdocs/v1.php"
+  string(27) "d:/www/phpnet/htdocs/v2.php"
   ["PHP_SELF"]=>
-  string(7) "/v1.php"
+  string(7) "/v2.php"
   ["argv"]=>
   array(0) {
   }


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon Dec 30 14:01:28 2024 UTC