ID:               47903
 Updated by:       ka...@php.net
 Reported By:      cFreed at orange dot fr
-Status:           Open
+Status:           Verified
-Bug Type:         Documentation problem
+Bug Type:         Scripting Engine problem
-Operating System: Win XP
+Operating System: Irrelevant
-PHP Version:      Irrelevant
+PHP Version:      5.2.9
 New Comment:

Verified in the PHP_5_2 branch only, PHP_5_3 and HEAD does not produce
this, reclassified


Previous Comments:
------------------------------------------------------------------------

[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';
$val...@$str[5];
// will issue the notice "Uninitialized string offset 5 in...".
?>



------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=47903&edit=1

Reply via email to