|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2000-11-17 22:05 UTC] bens at benjamindsmith dot com
<?
$string="?a=1&b=2";
if (!false===parse_str($string))
{
// all is happy
}
else {
// Whoops! error handling...
}
?>
I would submit that to maintain the elegant conventions of PHP, it would be good to return
A) The number of variables parsed (I'll leave in your court how to handle counting the # of array variables parsed)
or
B) false if the string was null, corrupt or "un-parsable".
Currently, the only way to evaluate the success of this function is to know the last variable that is/should be in the input stream and check to see that THAT variable exists after running this function = less than optimum.
Thanks!
-Ben
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Tue Oct 28 21:00:01 2025 UTC |
have parse_str return would be certainly good; as a workaround you can use parse_str( $s , $a ) ; if( 0 == count( $a ) ) { # problem ...