|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2001-12-16 02:15 UTC] mlemos at acm dot org
It seems that strtok function is broken again.
The following script returns:
<?
$first_token=strtok("/something","/");
$second_token=strtok("/");
var_dump($first_token,$second_token);
?>
Should output as always (at least until PHP 4.0.6 it does):
string(0) ""
string(9) "something"
But it outputs:
string(9) "something"
bool(false)
It seems that jmoore broken in when he tried to fix this bug:
http://bugs.php.net/bug.php?id=13866
I think that no developer should be allowed to fix bugs before:
1) submit a test case to leave in the tests directory
2) Verify that his fixes do not make his and others tests fail.
Until this procedure becomes mandatory, we'll keep seeing a history of illness in functions like strtok that seems to never end.
This is what regressive tests are for. Zak, please help here! :-)
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Nov 03 12:00:02 2025 UTC |
Nevermind my last posting. I was able to find a workaround :))) It would be cool if you would put this in the documentation I think ! To get the old strtok way: put this in your php documents and replace strtok with strtokold Function strtokold($string,$separator="") { static $next_token=''; if(!strcmp($separator,"")) { $separator=$string; $string=$next_token; } for($character=0;$character<strlen($separator);$character++) { if(GetType($position=strpos($string,$separator[$character]))=="integer") { $next_token=substr($string,$position+1); return(substr($string,0,$position)); } } $next_token=""; return($string); } tested and works FINE for me :))) thanks a bunch.