|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #52197 confusing description of return value 'strpos()'
Submitted: 2010-06-27 17:55 UTC Modified: 2010-06-27 18:47 UTC
From: gearond at sbcglobal dot net Assigned:
Status: Not a bug Package: Documentation problem
PHP Version: Irrelevant OS: ubuntu
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
Solve the problem:
50 - 49 = ?
Subscribe to this entry?

 [2010-06-27 17:55 UTC] gearond at sbcglobal dot net
I originally submitted the material below this paragraph, but it has been discussed before - WITH the exception of the "" return value. There needs to be some description of circumstances under which "" gets returned. Otherwise it's a random response, and we programmers like finite responses :-)

The function prototype on the document page says it returns an INT. The pink warning box at the bottom says it might return INT, BOOL, "". The return type should be set to MIXED.

And in what case, given the decscription of this function's operation, would it return an empty string?

Test script:
Not needed

Expected result:

Actual result:


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2010-06-27 18:47 UTC]
-Status: Open +Status: Bogus
 [2010-06-27 18:47 UTC]
It will never return empty string.

It can however return int(0) and bool(false) which is what the note is about.
Never do if(strpos($haystack, $needle)) {} to check if the $needle is in the 

This is clearly demonstrated by the examples on the page.
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Sun Sep 19 12:03:36 2021 UTC