Bug #68617 [Nab]: numeric interpretation of false

From: Date: Wed, 17 Dec 2014 19:29:47 +0000
Subject: Bug #68617 [Nab]: numeric interpretation of false
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-189101@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=68617&edit=1 ID: 68617 User updated by: r dot putz at gmx dot de Reported by: r dot putz at gmx dot de Summary: numeric interpretation of false Status: Not a bug Type: Bug Package: Strings related Operating System: any PHP Version: 5.5.19 Block user comment: N Private report: N New Comment: 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..;-) Previous Comments: ------------------------------------------------------------------------ [2014-12-17 18:54:00] requinix@php.net 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 http://www.php.net/support.php 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 16:47:48] r dot putz at gmx dot de Description: ------------ --- From manual page: http://www.php.net/function.substr-replace --- 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"; */ ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=68617&edit=1

« previous php.bugs (#189101) next »