note 90083 added to language.operators.errorcontrol
| From: | cFreed at orange dot fr | Date: | Sun, 05 Apr 2009 18:44:33 +0000 |
| Subject: | note 90083 added to language.operators.errorcontrol | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-152836@lists.php.net to get a copy of this message | ||
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...".
?>
----
Server IP: 89.31.146.176
Probable Submitter: 86.202.83.30
----
Manual Page -- http://www.php.net/manual/en/language.operators.errorcontrol.php
Edit -- https://master.php.net/note/edit/90083
Del: integrated -- https://master.php.net/note/delete/90083/integrated
Del: useless -- https://master.php.net/note/delete/90083/useless
Del: bad code -- https://master.php.net/note/delete/90083/bad+code
Del: spam -- https://master.php.net/note/delete/90083/spam
Del: non-english -- https://master.php.net/note/delete/90083/non-english
Del: in docs -- https://master.php.net/note/delete/90083/in+docs
Del: other reasons-- https://master.php.net/note/delete/90083
Reject -- https://master.php.net/note/reject/90083
Search -- https://master.php.net/manage/user-notes.php