note 83270 added to language.variables.predefined
| From: | mvpetrovich at osu1 dot php dot net | Date: | Sun, 18 May 2008 05:52:27 +0000 |
| Subject: | note 83270 added to language.variables.predefined | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-139498@lists.php.net to get a copy of this message | ||
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;
}
?>
----
Server IP: 208.69.120.35
Probable Submitter: 24.20.177.246
----
Manual Page -- http://www.php.net/manual/en/language.variables.predefined.php
Edit -- https://master.php.net/note/edit/83270
Del: integrated -- https://master.php.net/note/delete/83270/integrated
Del: useless -- https://master.php.net/note/delete/83270/useless
Del: bad code -- https://master.php.net/note/delete/83270/bad+code
Del: spam -- https://master.php.net/note/delete/83270/spam
Del: non-english -- https://master.php.net/note/delete/83270/non-english
Del: in docs -- https://master.php.net/note/delete/83270/in+docs
Del: other reasons-- https://master.php.net/note/delete/83270
Reject -- https://master.php.net/note/reject/83270
Search -- https://master.php.net/manage/user-notes.php