Bug #52197 [Opn->Bgs]: confusing description of return value 'strpos()'

From: Date: Sun, 27 Jun 2010 16:47:16 +0000
Subject: Bug #52197 [Opn->Bgs]: confusing description of return value 'strpos()'
References: 1  Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-4603@lists.php.net to get a copy of this message
Edit report at http://bugs.php.net/bug.php?id=52197&edit=1 ID: 52197 Updated by: bjori@php.net Reported by: gearond at sbcglobal dot net Summary: confusing description of return value 'strpos()' -Status: Open +Status: Bogus Type: Bug Package: Documentation problem Operating System: ubuntu PHP Version: Irrelevant New Comment: 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 $haystack. This is clearly demonstrated by the examples on the page. Previous Comments: ------------------------------------------------------------------------ [2010-06-27 17:55:29] gearond at sbcglobal dot net Description: ------------ 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: ---------------- n/a Actual result: -------------- n/a ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/bug.php?id=52197&edit=1

« previous php.doc.bugs (#4603) next »