#47903 [NEW]: Precision about "@" operator
| From: | cFreed at orange dot fr | Date: | Sun, 05 Apr 2009 19:05:35 +0000 |
| Subject: | #47903 [NEW]: Precision about "@" operator | ||
| Groups: | php.doc.bugs | ||
| Request: | Send a blank email to doc-bugs+get-2083@lists.php.net to get a copy of this message | ||
From: cFreed at orange dot fr
Operating system: Win XP
PHP version: Irrelevant
PHP Bug Type: Documentation problem
Bug description: Precision about "@" operator
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 bug report at http://bugs.php.net/?id=47903&edit=1
--
Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=47903&r=trysnapshot52
Try a CVS snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=47903&r=trysnapshot53
Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=47903&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=47903&r=fixedcvs
Fixed in CVS and need be documented: http://bugs.php.net/fix.php?id=47903&r=needdocs
Fixed in release: http://bugs.php.net/fix.php?id=47903&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=47903&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=47903&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=47903&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=47903&r=support
Expected behavior: http://bugs.php.net/fix.php?id=47903&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=47903&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=47903&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=47903&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=47903&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=47903&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=47903&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=47903&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=47903&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=47903&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=47903&r=mysqlcfg