Forum Moderators: coopster

Message Too Old, No Replies

Same superglobal variable names

         

PHPycho

4:12 am on Jun 27, 2007 (gmt 0)

10+ Year Member



Hello forums!
I am curious about some questions.
what happens when the session name and the $_POST vars or $_GET vars names are same.
ie
$_SESSION['sess_name'] = "xyz";

$_GET['sess_name'] = "abc" ;
Thanks in advance to all of you.

Habtom

4:51 am on Jun 27, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



May be you are not expecting a response as short as this, but they are two different, and the values don't over ride each other. Try the following:

file_name.ph?sess_name="abc"

<?php
$_SESSION['sess_name'] = "xyz";
echo $_SESSION['sess_name'];
echo $_GET['sess_name'];
?>

And you will get an output of
xyz
abc

Habtom