php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #5745 strpos returns false if match on first character
Submitted: 2000-07-23 12:18 UTC Modified: 2000-07-23 12:20 UTC
From: steve at srtware dot com Assigned:
Status: Closed Package: Misbehaving function
PHP Version: 4.0.1pl2 OS: Windows 98 SE
Private report: No CVE-ID: None
 [2000-07-23 12:18 UTC] steve at srtware dot com
if (strpos('abcde', 'abc')) {
(...)

will evaluate as false since the value returned is zero.  The documentation says it will return false if the string is not found.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2000-07-23 12:20 UTC] stas at cvs dot php dot net
Yes it returns zero. It is not a bug. Use another condition to detect "not found" case.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Jun 13 15:01:34 2024 UTC