From: christoph at ziegenberg dot de
Operating system: Win XP
PHP version: 5.2.0
PHP Bug Type: mbstring related
Bug description: More differences beetween functions and the mbstring versions
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
--
Edit bug report at http://bugs.php.net/?id=39400&edit=1
--
Try a CVS snapshot (PHP 4.4):
http://bugs.php.net/fix.php?id=39400&r=trysnapshot44
Try a CVS snapshot (PHP 5.2):
http://bugs.php.net/fix.php?id=39400&r=trysnapshot52
Try a CVS snapshot (PHP 6.0):
http://bugs.php.net/fix.php?id=39400&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=39400&r=fixedcvs
Fixed in release:
http://bugs.php.net/fix.php?id=39400&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=39400&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=39400&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=39400&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=39400&r=support
Expected behavior: http://bugs.php.net/fix.php?id=39400&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=39400&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=39400&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=39400&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=39400&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=39400&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=39400&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=39400&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=39400&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=39400&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=39400&r=mysqlcfg