php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #13419 strtok doesn't properly work with "#" as a token
Submitted: 2001-09-24 15:29 UTC Modified: 2001-09-24 19:04 UTC
From: ckoontz at yahoo dot com Assigned:
Status: Not a bug Package: Strings related
PHP Version: 4.0.6.7rc2 OS: linux 2.4.9 (debian unstable)
Private report: No CVE-ID: None
 [2001-09-24 15:29 UTC] ckoontz at yahoo dot com
in the following code:
$string = "#This is an example string";
$tok1 = strtok($string,"#");

$tok1 should equal nothing.. however it equals $string

This bug breaks ACID:
http://www.cert.org/kb/acid/

people on IRC have verified that this bug is also in CVS as of this report

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-09-24 16:17 UTC] mfischer@php.net
This is not a bug. This is the way strtok() works. Although PHP uses its own implementation, strtok() under C works the same and PHP mimics the C version (anything else would render this function useless).

No bug, bogusifying.

If you need similar functionality take a look at explode()/split()

- Markus
 [2001-09-24 19:04 UTC] ckoontz at yahoo dot com
If this is bogus.. make sure you document the change...
doing strtok($moo,"#") worked fine in earler releases...
I'm fairly certian it worked in 4.0.6


 [2002-09-19 04:07 UTC] luca-80 at libero dot it
I have found a way to run this correct:

In acid_common.php
replace the script in /* ... */
with my one, that's work


/*  
  strtok($submit,"#");
  $seq = strtok("-");     
         strtok("(");
  $sid = strtok("-");
  $cid = strtok(")");

*/

  $boo = ereg_replace ("\#", " ", $submit);  
  $boo = ereg_replace ("\(", " ", $boo);    
  $boo = ereg_replace ("\)", " ", $boo);    
  $boo = trim($boo);    
  $pieces = explode("-", $boo);  
  $seq = $pieces[0];
  $sid = $pieces[1];
  $cid = $pieces[2];
 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Mon Dec 16 14:01:25 2019 UTC