Hello,
I'm migrating some sites to a new server that has PHP 5 installed on it and I'm changing all my old code to be compatable w/ PHP5.
My question is that it seems that PHP5 requires that you declare your global vars before you use them.
I you set your $_REQUEST vars at the beginning of the page you nix them when the page is submitted via a form.
Here's an example:
<?
#---- declare vars -------------------
$_REQUEST['username'] = '';
$_REQUEST['password'] = '';
#---------------------------------------
echo "<p> username: " . $_REQUEST['username'] . " password: " . $_REQUEST['password']; // once the form is submitted the above declaration will reset the set request variables
?>
How would you get around this?
Thanks,
Clem C.it seems that PHP5 requires that you declare your global vars before you use them
Variables should be decalred in ALL versions before you use them. The easeiest way is to check first. eg;
$username = isset($_POST['username']) ? $_POST['username'] : '';
I'm migrating some sites to a new server that has PHP 5 installed on it and I'm changing all my old code to be compatable w/ PHP5.
My question is that it seems that PHP5 requires that you declare your global vars before you use them.
I you set your $_REQUEST vars at the beginning of the page you nix them when the page is submitted via a form.
Here's an example:
<?
#---- declare vars -------------------
$_REQUEST['username'] = '';
$_REQUEST['password'] = '';
#---------------------------------------
echo "<p> username: " . $_REQUEST['username'] . " password: " . $_REQUEST['password']; // once the form is submitted the above declaration will reset the set request variables
?>
How would you get around this?
Thanks,
Clem C.it seems that PHP5 requires that you declare your global vars before you use them
Variables should be decalred in ALL versions before you use them. The easeiest way is to check first. eg;
$username = isset($_POST['username']) ? $_POST['username'] : '';