#47903 [Asn->Csd]: "@" operator does not work with string offsets (PHP_5_2 only!)

From: Date: Mon, 06 Apr 2009 23:57:20 +0000
Subject: #47903 [Asn->Csd]: "@" operator does not work with string offsets (PHP_5_2 only!)
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-135612@lists.php.net to get a copy of this message
ID: 47903 Updated by: felipe@php.net Reported By: cFreed at orange dot fr -Status: Assigned +Status: Closed Bug Type: Scripting Engine problem Operating System: * PHP Version: 5.2.9 Assigned To: felipe New Comment: This bug has been fixed in CVS. Snapshots of the sources are packaged every three hours; this change will be in the next snapshot. You can grab the snapshot at http://snaps.php.net/. Thank you for the report, and for helping us make PHP better. Previous Comments: ------------------------------------------------------------------------ [2009-04-06 11:59:28] felipe@php.net Yes, these fix was just committed in 5.3+. ------------------------------------------------------------------------ [2009-04-06 11:40:45] jani@php.net Felipe, this same (?) issue was reported in bug #39018 and was supposed to be closed too..was the fix omitted from PHP_5_2 branch? ------------------------------------------------------------------------ [2009-04-06 08:34:36] kalle@php.net Verified in the PHP_5_2 branch only, PHP_5_3 and HEAD does not produce this, reclassified ------------------------------------------------------------------------ [2009-04-05 19:05:35] cFreed at orange dot fr Description: ------------ A case where the error-control operator @ does NOT work, despite of what the manual says. Reproduce code: --------------- --- From manual page: language.operators.errorcontrol --- The manual says: "A simple rule of thumb is: if you can take the value of something, you can prepend the @ operator to it." This is not always true. As shown by the example given, this works, assuming $cache IS AN ARRAY: <?php $value = @$cache[$key]; // will not issue a notice if the index $key doesn't exist. ?> But it does not work if $cache IS A STRING, and $key is an integer higher than strlen($cache)-1. in other words: <?php $str='abc'; $value=@$str[5]; // will issue the notice "Uninitialized string offset 5 in...". ?> ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=47903&edit=1

« previous php.bugs (#135612) next »