#50710 [Opn->Bgs]: stripos returns FALSE for empty string used as needle
| From: | jani@php.net | Date: | Sun, 10 Jan 2010 22:37:04 +0000 |
| Subject: | #50710 [Opn->Bgs]: stripos returns FALSE for empty string used as needle | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-146514@lists.php.net to get a copy of this message | ||
ID: 50710
Updated by: jani@php.net
Reported By: miklcct at gmail dot com
-Status: Open
+Status: Bogus
-Bug Type: Feature/Change Request
+Bug Type: Strings related
Operating System: Ubuntu 9.10
PHP Version: 5.3.1
New Comment:
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to
report
a bug at http://bugs.php.net/how-to-report.php
,
Previous Comments:
------------------------------------------------------------------------
[2010-01-10 09:34:37] rasmus@php.net
By that logic shouldn't it always return true then? There is an empty
string everywhere in a string. Before the first char, between each
char, etc. Not sure that is a useful result though.
------------------------------------------------------------------------
[2010-01-10 09:28:38] miklcct at gmail dot com
Description:
------------
The function stripos() returns FALSE when a empty string is used.
Consider the example below, an empty string is used and it is found at
position 0. It is misleading (at least theoretically) that an empty
string is not found inside another string.
Reproduce code:
---------------
<?php
var_dump(stripos('test', 'te'));
var_dump(stripos('test', 't'));
var_dump(stripos('test', ''));
var_dump(stripos('test', 'es', 1));
var_dump(stripos('test', 'e', 1));
var_dump(stripos('test', '', 1));
var_dump(stripos('test', '', 2));
var_dump(stripos('', ''));
?>
Expected result:
----------------
int(0)
int(0)
int(0)
int(1)
int(1)
int(1)
int(2)
int(0)
Actual result:
--------------
int(0)
int(0)
bool(false)
int(1)
int(1)
bool(false)
bool(false)
bool(false)
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=50710&edit=1