|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #47903 "@" operator does not work with string offsets (PHP_5_2 only!)
Submitted: 2009-04-05 19:05 UTC Modified: 2009-04-06 23:57 UTC
From: cFreed at orange dot fr Assigned: felipe (profile)
Status: Closed Package: Scripting Engine problem
PHP Version: 5.2.9 OS: *
Private report: No CVE-ID: None
 [2009-04-05 19:05 UTC] cFreed at orange dot fr
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:
$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:
// will issue the notice "Uninitialized string offset 5 in...".


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2009-04-06 08:34 UTC]
Verified in the PHP_5_2 branch only, PHP_5_3 and HEAD does not produce this, reclassified
 [2009-04-06 11:40 UTC]
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 11:59 UTC]
Yes, these fix was just committed in 5.3+.
 [2009-04-06 23:57 UTC]
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
Thank you for the report, and for helping us make PHP better.

PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Tue Jul 05 07:05:46 2022 UTC