note 54104 added to reserved.variables
| From: | php-general at lists dot php dot net | Date: | Thu, 23 Jun 2005 20:04:24 +0000 |
| Subject: | note 54104 added to reserved.variables | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-90858@lists.php.net to get a copy of this message | ||
It took me a long time to find this and I thought I would share...
look at how much coding you save...
Use this...
$p =& $_POST;
extract($p);
Instead of this ...
$username = $HTTP_POST_VARS['username'];
$passwd = $HTTP_POST_VARS['passwd'];
if(isset($HTTP_POST_VARS['action']))
$action = $HTTP_POST_VARS['action'];
else
$action = $HTTP_GET_VARS['action'];
if(isset($HTTP_POST_VARS['account']))
$account = $HTTP_POST_VARS['account'];
else
$account = $HTTP_GET_VARS['account'];
$messageid = $HTTP_GET_VARS['messageid'];
$to = $HTTP_POST_VARS['to'];
$cc = $HTTP_POST_VARS['cc'];
$subject = $HTTP_POST_VARS['subject'];
$message = $HTTP_POST_VARS['message'];
This returns the post
$p =& $_POST; <<< this builds an array of your Vars
an places them in $p (array)
If you print_r($p); you will
understand
extract($p); <<< This extracts the data into the vars
automatically...
So from above the $action
$username $to $cc are all filled in...
Now you say but wait I have something called $cc then lookup the extract function and you will love
this time saver!
----
Manual Page -- http://www.php.net/manual/en/reserved.variables.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+54104
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+54104&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+54104&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+54104&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+54104&report=yes&reason=useless
Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+54104&report=yes&reason=non-english
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+54104&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+54104&report=yes
Search -- http://master.php.net/manage/user-notes.php