|
Posted by www.douglassdavis.com on 10/11/05 19:22
For example, if I put this code in a file called globaltest.php:
$new_var="This is a string";
class TestClass
{
function __construct()
{
global $new_var;
echo "<br>new var: ".$new_var;
}
function testFunc()
{
global $new_var;
echo "<br>new var in testFunc(): ".$new_var;
echo "<br>from globals ".$GLOBALS['new_var'];
}
}
$testo=new TestClass();
$testo->testFunc();
It displays
new var: This is a string
new var in testFunc(): This is a string
from globals This is a string
as it should.
However, when I put it in another file that is an included php file, it
doesn't even register new_var as a global, and I get this printed out:
new var:
new var in testFunc():
from globals
I don't understand. What could possibly be making this happen? Right
now I am looking for any possibilities, because to me, it doesn't seem
to make sense.
I am using 5.0.4, but, the same happens in 5.0.5
[Back to original message]
|