#43467 [Opn]: function substr() does not function the same

From: Date: Sat, 01 Dec 2007 11:28:24 +0000
Subject: #43467 [Opn]: function substr() does not function the same
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-120262@lists.php.net to get a copy of this message
ID: 43467 Updated by: felipe@php.net Reported By: mgd at xpressbillpay dot com Status: Open Bug Type: Unknown/Other Function Operating System: Windows XP and server 2003 PHP Version: 5.2.5 New Comment: Anyway, says the documentation: "If start denotes a position beyond this truncation, an empty string will be returned." Previous Comments: ------------------------------------------------------------------------ [2007-12-01 08:50:51] mgd at xpressbillpay dot com Description: ------------ script using substr($strVal, -10); if $strVal length is less then 10 chars (or less then int start) the return value is empty. In a previous version(I had 5.1.4 before upgrade) substr($strVal, -10); would still return the full #strVal if less then 10 which it should since int start should begin from the last character and count back x number of chars and stop at the first if $strVal is less the the count. Reproduce code: --------------- <?PHP $str = "1234567"; echo substr($str,-8); ?> Expected result: ---------------- 1234567 Actual result: -------------- empty ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=43467&edit=1

« previous php.bugs (#120262) next »