|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #68617 numeric interpretation of false
Submitted: 2014-12-17 16:47 UTC Modified: 2014-12-17 19:29 UTC
From: r dot putz at gmx dot de Assigned:
Status: Not a bug Package: Strings related
PHP Version: 5.5.19 OS: any
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: r dot putz at gmx dot de
New email:
PHP Version: OS:


 [2014-12-17 16:47 UTC] r dot putz at gmx dot de
From manual page:

in substr_replace param start = false is interpreted as numeric position 0.

(interpreting 0 as false maybe ok, but the other way round?..)

Test script:
/* example replacing delemiter in a string */

$string = "foo1, foo2, foo3";
$string = substr_replace($string, ' and', strrpos($string, ','), 1);
echo $string;
/* output as expected: "foo1, foo2 and foo3"; */

/* no delemiter in string so should do nothing */
$string = "foo1";
$string = substr_replace($string, ' and', strrpos($string, ','), 1);
echo $string;
/* wrong output: " andoo1"; */


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2014-12-17 18:54 UTC]
-Status: Open +Status: Not a bug
 [2014-12-17 18:54 UTC]
Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit as this bug system is not the
appropriate forum for asking support questions.  Due to the volume
of reports we can not explain in detail here why your report is not
a bug.  The support channels will be able to provide an explanation
for you.

Thank you for your interest in PHP.

You need to do your own error checking. For all substr_replace() knows, using false/0 *is* what you want it to do.
 [2014-12-17 19:29 UTC] r dot putz at gmx dot de
sure do my own error checking!
mainly complaining about strange behaviour interpreting false as numeric in general (whereas vice versa it makes sense, even though not nice..;-)
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Jul 24 09:01:30 2024 UTC