Bug #72824 [Opn->Nab]: substr length of 08 or 09 fails (8 or 9 return valid results)

From: Date: Fri, 12 Aug 2016 21:38:53 +0000
Subject: Bug #72824 [Opn->Nab]: substr length of 08 or 09 fails (8 or 9 return valid results)
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-203225@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=72824&edit=1 ID: 72824 Updated by: requinix@php.net Reported by: crsthorn at gmail dot com Summary: substr length of 08 or 09 fails (8 or 9 return valid results) -Status: Open +Status: Not a bug Type: Bug Package: Strings related Operating System: Linux PHP Version: Irrelevant Block user comment: N Private report: N New Comment: The leading zero means you're writing numbers in octal, and 08 and 09 are invalid octal numbers. http://php.net/manual/en/language.types.integer.php Previous Comments: ------------------------------------------------------------------------ [2016-08-12 20:58:44] crsthorn at gmail dot com Description: ------------ PHP 5.5.9-1ubuntu4.17 (cli) (built: May 19 2016 19:05:57) Copyright (c) 1997-2014 The PHP Group Zend Engine v2.5.0, Copyright (c) 1998-2014 Zend Technologies with Zend OPcache v7.0.3, Copyright (c) 1999-2014, by Zend Technologies ==================================================================== This was also present in PHP 5.3.X versions When calling the substr function and passing it a length of 08 or 09 - it seems to return a null. Passing lengths of 8 or 9 return expected results. Test script: --------------- <?PHP $buffer = "This should work as expected."; echo substr($buffer , 0 , 1) ."\n"; echo substr($buffer , 0 , 01) ."\n"; echo substr($buffer , 0 , 7) ."\n"; echo substr($buffer , 0 , 07) ."\n"; echo substr($buffer , 0 , 8) ."\n"; echo substr($buffer , 0 , 08) ."\n"; //FAILS echo substr($buffer , 0 , 9) ."\n"; echo substr($buffer , 0 , 09) ."\n"; //FAILS echo substr($buffer , 0 , 10) ."\n"; echo substr($buffer , 0 , 10) ."\n"; ?> ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=72824&edit=1

« previous php.bugs (#203225) next »