PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
I've noticed this strange PHP behavior. Following example shows that these two variables, $_SESSION['name'] and $name are actually single variable. When one of them is given some value, the other takes this same value?!
session_start();
if (!session_is_registered('name')) session_register('name');
echo 'before:' . $_SESSION['name'];
$name = 'value 1';
echo '<br>after:' . $_SESSION['name']; // this should echo only 'after:' but it echoes 'after:value 1'
$_SESSION['name'] = 'value 2';
echo '<br>finally:' . $name; // this should echo 'finally:value 1' but it echoes 'finally:value 2'
This strange behavior had caused me many headaches in the past, until I have noticed it. I tried to google it but I don't know if PHP should behave like that or not?
Thank you, Ragnis. But before I send register_globals = Off request to my site's host, I'd like to know whether variables from my included PHP scripts will be visible from the main PHP file and vice versa?
As per security issue register_globals should be off, other all our POST,GET,and COOKIE data is visable for all.
Always register_globals = off; in php.ini file
Thanks
Anil.N
Thought Radius - Experts for Partners