I read php manual many times but I can't figure out register_global s
works. I m using Php 4.3.2 and register_global s on. It seems to have
different effects on $_GET and $_SESSION. First with $_GET :
<? echo $var."\n";
echo $_GET['var']."\n";
$var="gna";
echo $var."\n";
echo $_GET['var']."\n";
$_GET['var']="gnou";
echo $var."\n";
echo $_GET['var']."\n";
?>
This page is called by <a href="work3.php ?var=gni">work3 </a>.
And produce this output :
gni
gni
gna
gni
gna
gnou
What I understand is that before reading the script, a global variable
is created with the same name and value as _GET['var'] but these are
eventually two distinct variables.
Then with $_SESSION :
<? session_start() ;
$_SESSION['test3'] = 'this is a test3';
?>
<a href="work5.php ">work5</a>
and in work5.php
<? session_start() ;
echo $test3."\n";
echo $_SESSION['test3']."\n";
$test3="gna";
echo $test3."\n";
echo $_SESSION['test3']."\n";
$_SESSION['test3']="gnou";
echo $test3."\n";
echo $_SESSION['test3']."\n";?>
This produce :
this is a test3
this is a test3
gna
gna
gnou
gnou
What I understand here is that before reading the script, a global
variable is created with the same name and value as _SESSION['test3']
but they share the same memory.
Where does it comes from ? Is it an extra work from session_start() ?
works. I m using Php 4.3.2 and register_global s on. It seems to have
different effects on $_GET and $_SESSION. First with $_GET :
<? echo $var."\n";
echo $_GET['var']."\n";
$var="gna";
echo $var."\n";
echo $_GET['var']."\n";
$_GET['var']="gnou";
echo $var."\n";
echo $_GET['var']."\n";
?>
This page is called by <a href="work3.php ?var=gni">work3 </a>.
And produce this output :
gni
gni
gna
gni
gna
gnou
What I understand is that before reading the script, a global variable
is created with the same name and value as _GET['var'] but these are
eventually two distinct variables.
Then with $_SESSION :
<? session_start() ;
$_SESSION['test3'] = 'this is a test3';
?>
<a href="work5.php ">work5</a>
and in work5.php
<? session_start() ;
echo $test3."\n";
echo $_SESSION['test3']."\n";
$test3="gna";
echo $test3."\n";
echo $_SESSION['test3']."\n";
$_SESSION['test3']="gnou";
echo $test3."\n";
echo $_SESSION['test3']."\n";?>
This produce :
this is a test3
this is a test3
gna
gna
gnou
gnou
What I understand here is that before reading the script, a global
variable is created with the same name and value as _SESSION['test3']
but they share the same memory.
Where does it comes from ? Is it an extra work from session_start() ?