note 83270 deleted from language.variables.predefined by googleguy

From: Date: Tue, 22 Oct 2013 11:00:03 +0000
Subject: note 83270 deleted from language.variables.predefined by googleguy
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-196998@lists.php.net to get a copy of this message
Note Submitter: mvpetrovich ---- Here is a function to get all your variables of interest. It uses the "parse_str function" and lets you enter your variable names as a space-delimited list. It's a quick way to get your variables. Note that in this function I strip tags, and trim the result. The function produces a "Query String" which is fed into the "parse_str_function." Example: <?php parse_str(PostGetStr('NAME PASSWORD SUBMIT','POST')); ?> This will produce three variables, $NAME, $PASSWORD, and $SUBMIT. If they were undefined, they will be null strings, ie, $NAME=''. <?php function PostGetStr($str,$type){ $VARS = explode(' ',$str); $RESULT = ''; if($type == 'POST'){ foreach($VARS as $PV) if(isset($_POST[$PV])) { $RESULT .= "$PV=".trim(strip_tags($_POST[$PV])).'&'; } else {$RESULT .= "$PV=&";} } elseif($type == 'GET'){ foreach($VARS as $PV) if(isset($_GET[$PV])) { $RESULT .= "$PV=".trim(strip_tags($_GET[$PV])).'&'; } else {$RESULT .= "$PV=&";} } elseif($type == 'BOTH'){ foreach($VARS as $PV) if(isset($_REQUEST[$PV])) { $RESULT .= "$PV=".trim(strip_tags($_REQUEST[$PV])).'&'; } else {$RESULT .= "$PV=&";} } $RESULT = substr($RESULT,0,-1); return $RESULT; } ?>

« previous php.notes (#196998) next »