php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #62145 strpos returns null instead of false
Submitted: 2012-05-24 20:19 UTC Modified: 2012-05-27 20:46 UTC
From: maddok01 at hotmail dot com Assigned:
Status: Not a bug Package: *General Issues
PHP Version: 5.3.13 OS: linux hardy
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: maddok01 at hotmail dot com
New email:
PHP Version: OS:

 

 [2012-05-24 20:19 UTC] maddok01 at hotmail dot com
Description:
------------
---
From manual page: http://www.php.net/function.strpos#refsect1-function.strpos-returnvalues
---

If the input to strpos is invalid the function used to return false.  Now it returns null.  Null is not a documented return value for this function.

Test script:
---------------
php -r 'var_export( @strpos( array( "" ), "test",  0 ) );echo "\n";'

Before php 5.3
false

After PHP 5.3
NULL


Expected result:
----------------
false

Actual result:
--------------
NULL

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2012-05-24 23:35 UTC] felipe@php.net
-Type: Bug +Type: Documentation Problem
 [2012-05-25 01:58 UTC] laruence@php.net
-Status: Open +Status: Not a bug
 [2012-05-25 01:58 UTC] laruence@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

not found and invalid argument are differenet.
 [2012-05-27 20:46 UTC] johannes@php.net
See note in http://php.net/functions.internal we don't document that for all functions individually.
 [2016-09-12 10:40 UTC] net dot monitor dot x at gmail dot com
Please fix the documentation

http://php.net/manual/en/function.strpos.php

it still report false but all recent versions of PHP return NULL
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Mon Jul 14 09:01:31 2025 UTC