php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #39400 More differences beetween functions and the mbstring versions
Submitted: 2006-11-06 13:21 UTC Modified: 2006-12-22 07:47 UTC
Votes:6
Avg. Score:4.3 ± 0.7
Reproduced:6 of 6 (100.0%)
Same Version:6 (100.0%)
Same OS:1 (16.7%)
From: s dot masugata at mbg dot nifty dot com Assigned: masugata (profile)
Status: Closed Package: mbstring related
PHP Version: 5.2.0 OS: Win XP
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: s dot masugata at mbg dot nifty dot com
New email:
PHP Version: OS:

 

 [2006-11-06 13:21 UTC] s dot masugata at mbg dot nifty dot com
Description:
------------
I posted a bug for the wrong behaviour of mb_strstr() compared to strstr() before - this has been fixed, but also the other functions behave different.

Here a code to see more differences: 

- different behaviours between functions and the mbstring versions,
- different error messages and 
- different behaviour between a function and the case-insensitive version

Reproduce code:
---------------
<?php
print('stripos (empty haystack):<br />');
stripos('', ',', 0);
mb_stripos('', ',', 0);

print('<br />stripos (offest > length):<br />');
stripos('1', ',', 3);
mb_stripos('1', ',', 3);

print('<br />strripos (empty haystack):<br />');

strripos('', ',', 0);
mb_strripos('', ',', 0);

print('<br />strripos (offest > length):<br />');
strripos('1', ',', 3);
mb_strripos('1', ',', 3);

print('<br />stristr (empty haystack):<br />');
stristr('', ',');
mb_stristr('', ',');

print('<br />strrichr (empty haystack):<br />');
strrchr('', ',');
mb_strrchr('', ',');
?>

Expected result:
----------------
stripos (empty haystack):

stripos (offest > length):

[same error message, dunno which is the better one - they mean the same, but it would be better to get the same text. or no error as in strripos(), see below.]

strripos (empty haystack):

strripos (offest > length):

[same as for stripos() - strripos() returns no error here]

stristr (empty haystack):

strrichr (empty haystack):

Actual result:
--------------
stripos (empty haystack):

Warning: mb_stripos() [function.mb-stripos]: Empty haystack in W:\www\mb_functions.php on line 4

stripos (offest > length):

Warning: stripos() [function.stripos]: Offset not contained in string. in W:\www\mb_functions.php on line 7

Warning: mb_stripos() [function.mb-stripos]: Offset is out of range in W:\www\mb_functions.php on line 8

strripos (empty haystack):

Warning: mb_strripos() [function.mb-strripos]: Empty haystack in W:\www\mb_functions.php on line 13

strripos (offest > length):

Warning: mb_strripos() [function.mb-strripos]: Offset is out of range in W:\www\mb_functions.php on line 17

stristr (empty haystack):

Warning: mb_stristr() [function.mb-stristr]: Empty haystack in W:\www\mb_functions.php on line 21

strrichr (empty haystack):

Warning: mb_strrchr() [function.mb-strrchr]: Empty haystack in W:\www\mb_functions.php on line 25

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-11-06 15:47 UTC] christoph at ziegenberg dot de
Point "different behaviour between a function and the case-insensitive version" isn't right, I meant the difference between stripos() and strripos() (which behave equal in the mbstring version).
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Nov 21 13:01:29 2024 UTC