#47903 [Opn->Ver]: Precision about "@" operator

From: Date: Mon, 06 Apr 2009 08:34:37 +0000
Subject: #47903 [Opn->Ver]: Precision about "@" operator
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-135560@lists.php.net to get a copy of this message
ID: 47903 Updated by: kalle@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'; $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

« previous php.bugs (#135560) next »