php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #23215 strstr does not return return all from found needle to the end of the string
Submitted: 2003-04-14 20:24 UTC Modified: 2003-04-14 22:04 UTC
From: gorkha at brillianet dot com Assigned:
Status: Not a bug Package: Strings related
PHP Version: 4.3.0 OS: linux redhat 8.0
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: gorkha at brillianet dot com
New email:
PHP Version: OS:

 

 [2003-04-14 20:24 UTC] gorkha at brillianet dot com
Example of the bug:

$teststring="John\0Smith";
print strstr($teststring,"oh");

It will now only print out 'ohn', because strstr only returns to the '\0' and not the rest of the string.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-04-14 22:04 UTC] pollita@php.net
Please double check both your PHP version and your test script.  strstr() is binary safe in PHP 4.3.0

Local test with your exact script returns:

ohnSmith

Additionally, var_dump(strstr($teststring,"oh")); returns:

string(9) "ohnSmith" which reveals the hidden (non-printing) null character.

If you have additional information which can lead to the reproduction of this bug, please feel free to add it here and reclassify the bug to 'open'.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Apr 23 13:01:29 2024 UTC