Ask a Question related to PHP Development, Design and Development.
-
sniper@php.net #1
#26292 [Opn->Bgs]: substr returns "0" for any offset on the string "0"
ID: 26292
Updated by: [email]sniper@php.net[/email]
Reported By: ravacholp at hotmail dot com
-Status: Open
+Status: Bogus
Bug Type: Strings related
Operating System: windows 2000
PHP Version: 4.3.2
New Comment:
With a more reliable test script:
# cat t.php
<?php
$str = "0";
var_dump(substr($str, 0, 1));
var_dump(substr($str, 1, 1));
var_dump(substr($str, 5, 1));
?>
# php t.php
string(1) "0"
bool(false)
bool(false)
No bug here.
Previous Comments:
------------------------------------------------------------------------
[2003-11-17 17:16:07] ravacholp at hotmail dot com
Description:
------------
substr() returns "0" for any offset on the string "0" using the length
1.
This causes an infinite loop if you are checking for leading zeros in
your string using substr().
Reproduce code:
---------------
$str = "0";
print (substr($str, 0, 1) == "0");
print (substr($str, 1, 1) == "0");
print (substr($str, 5, 1) == "0");
// only the first line should evaluate to true
Expected result:
----------------
111
------------------------------------------------------------------------
--
Edit this bug report at [url]http://bugs.php.net/?id=26292&edit=1[/url]
sniper@php.net Guest
-
#39018 [NEW]: Error control operator '@' fails to suppress "Uninitialized string offset"
From: mpb dot mail at gmail dot com Operating system: Gentoo Linux PHP version: 5.1.6 PHP Bug Type: Scripting Engine problem... -
"Error Creating Control" and "Cast from String"
I'm creating a custom date control. In appearance, it's just a textbox and a button. It has three custom properties: CalDate, CalDateType and... -
Servervariables("logon_user") returns empty string
Hi, Is the Anonymous access trued off in IIS? JN NSQUARED2 -
dr("field").toString returns "400.0000" instead of "400"
I have just installed VS.NET 2003 on my computer. I have a project that I have been developing on VS.NET 2002. I haven't upgraded this project to... -
convert visual basic "string" data type to DB2 "blob"
Does anyone know if a visual basic string data type can be converted to DB2 blob datatype? I have all data in XML files and I use Visual Basic to...



Reply With Quote

