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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: steve at srtware dot com
New email:
PHP Version: OS:

 

 [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

Pull Requests

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-2025 The PHP Group
All rights reserved.
Last updated: Wed Jul 02 14:01:36 2025 UTC