note 56289 added to language.variables.predefined

From: Date: Mon, 29 Aug 2005 21:33:32 +0000
Subject: note 56289 added to language.variables.predefined
Groups: php.notes 
Request: Send a blank email to php-notes+get-94355@lists.php.net to get a copy of this message
# this is a follow-up to kasey at cornerspeed's 14-Jun-2004 08:33 post and debabratak at softhome's 14-Mar-2003 12:59 post, minus sessions but including a safety mechanism to block unwanted variables... # if you are like me and do not want to have to type $_POST[some_var] to get to all your passed variable data, you can safely convert all the data to the variable names (so it is like old style php) by using a pre-defined allowed arg names list like this; $allowed_args = ',f_name,l_name,subject,msg,'; foreach(array_keys($_POST) as $k) { $temp = ",$k,"; if(strpos($allowed_args,$temp) !== false) { $$k = $_POST[$k]; } } # then you can use the programmer friendly (less typing) vars like so; echo "Hello $f_name"; # make sure you have commas in front of and after each var name in the $allowed_args list, so strpos will never surprise you by mistakingly finding an unwanted var name within another var name ---- Manual Page -- http://www.php.net/manual/en/language.variables.predefined.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+56289 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+56289&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+56289&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+56289&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+56289&report=yes&reason=useless Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+56289&report=yes&reason=non-english Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+56289&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+56289&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#94355) next »