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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
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: Thu Apr 25 19:01:33 2024 UTC