Anonymous | Login | Signup for a new account | 12-17-2024 10:57 PST |
Main | My View | View Issues | Change Log | Docs |
Viewing Issue Simple Details [ Jump to Notes ] | [ View Advanced ] [ Issue History ] [ Print ] | ||||||||
ID | Category | Severity | Reproducibility | Date Submitted | Last Update | ||||
0002495 | [Quercus] | minor | always | 03-05-08 20:18 | 03-06-08 16:40 | ||||
Reporter | pablorg | View Status | public | ||||||
Assigned To | nam | ||||||||
Priority | normal | Resolution | fixed | ||||||
Status | closed | Product Version | 3.1.5 | ||||||
Summary | 0002495: strpos is broken | ||||||||
Description |
Strpos should return an int. If the needle is not found, it should return -1. You can easily reproduce the bug every time:<? $bob = "12345"; $pos = strpos($bob, "_"); echo "pos:$pos\n"; if ($pos > -1) echo "pos > -1 (ERROR)"; else echo "OK"; ?> |
||||||||
Additional Information | |||||||||
Attached Files | |||||||||
|
Notes | |
(0002828) etzel 03-06-08 00:12 |
You're wrong. Quoting official docs "If needle is not found, strpos() will return >>>boolean<<< FALSE" See http://ru2.php.net/manual/en/function.strpos.php [^] |
(0002829) pablorg 03-06-08 06:12 |
Agreed. PHP doesnt respect the docs. I'd like to close the bug, but Mantis doesnt give me the option. |
(0002830) nam 03-06-08 06:42 |
pablorg, you have a good point. In the PHP docs, they say that strpos may or may not return FALSE when the needle is not found (though I am not sure if we want to track down all the cases where PHP is not returning FALSE). But in your test case, PHP's strpos does indeed return the type FALSE. The problem is that Quercus is evaulating 'FALSE > -1' as being true. |
(0002831) etzel 03-06-08 08:30 |
nam, according to the current strpos source (http://lxr.php.net/source/php-src/ext/standard/string.c#2531), [^] it always returns boolean false (RETURN_FALSE) when the string is not found. |
(0002832) nam 03-06-08 09:14 |
Thanks etzel for the heads-up. At Caucho, we cannot look at the PHP source for copyright reasons. Our only references are PHP's behavior and the docs. |
(0002834) nam 03-06-08 16:40 |
Fixed 'FALSE > -1': php/035p php/035q |
Mantis 1.0.0rc3[^]
Copyright © 2000 - 2005 Mantis Group
40 total queries executed. 32 unique queries executed. |