php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #7869 parse_str produces no trapable value
Submitted: 2000-11-17 22:05 UTC Modified: 2003-02-06 21:33 UTC
From: bens at benjamindsmith dot com Assigned:
Status: Not a bug Package: Feature/Change Request
PHP Version: 4.0.3pl1 OS: RH Linux 6.2
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: bens at benjamindsmith dot com
New email:
PHP Version: OS:

 

 [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 

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-01-21 03:57 UTC] cynic@php.net
have parse_str return would be certainly good; as a workaround you can use 

parse_str( $s , $a ) ;
if( 0 == count( $a ) ) {
   # problem
   ...
 [2003-02-06 21:33 UTC] iliaa@php.net
Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system is not the
appropriate forum for asking support questions. 

Thank you for your interest in PHP.

I believe that since there is a way to fetch the data in form of an array this feature request is mostly pointless.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Mar 28 16:01:29 2024 UTC