|  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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Bug Type:
From: gearond at sbcglobal dot net
New email:
PHP Version: OS:


 [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: Tue Sep 28 14:03:36 2021 UTC