php 5.2 register_globals setting not functionning

PHP 5.2, Windows 2003, Apache 2.0

Register_Globals are OFF in php.ini but global variables are still enabled. This is my test script:
No .htaccess files are present.

$test="hello world";

function testfunc()
global $test;
echo $test;

It produces the following output: hello world

Is there another setting that manages the global variables for PHP???
Who is Participating?
TeRReFConnect With a Mentor Commented:
The global keyword takes vars from the gobal scope inside the function. You cannot disable that, it's part of the language constructs.

Register globals is a different story, that is evil and should be off indeed...
Yes, this :)

global $test;

Remove that and it won't work anymore
glcumminsConnect With a Mentor Commented:
You can use the global keyword to make any script variable available in within a function, regardless of the register_globals setting. That setting is for situations like this:

A script is called with this query string: index.php?username=Bob

Now if register_globals is on, a variable named '$username' is automatically created:
echo $username; // Output is 'Bob'

Obviously this is a security concern in some cases, because you don't want variables created without your explicit instructions. That is why register_globals is now off by default.
vanaudenAuthor Commented:
ok I understand -

follow up question:

does the global keyword also work in php version 4??
According to the PHP manual on this topic, the keyword does exists in PHP 4:
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.