#47903 [Ver->Asn]: "@" operator does not work with string offsets (PHP_5_2 only!)
| From: | jani@php.net | Date: | Mon, 06 Apr 2009 11:40:46 +0000 |
| Subject: | #47903 [Ver->Asn]: "@" 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-135573@lists.php.net to get a copy of this message | ||
ID: 47903
Updated by: jani@php.net
Reported By: cFreed at orange dot fr
-Status: Verified
+Status: Assigned
Bug Type: Scripting Engine problem
Operating System: *
PHP Version: 5.2.9
-Assigned To:
+Assigned To: felipe
New Comment:
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?
Previous Comments:
------------------------------------------------------------------------
[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