|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2001-11-15 02:33 UTC] mfischer at guru dot josefine dot at
When setting error_reporting(E_ALL) the following occurs:
<?
error_reporting(E_ALL);
$foo = array(); echo $foo[0] . "\n"; // <-- warning
$foo = array(); echo @$foo[0]. "\n"; // <-- no warning
$foo = "foo"; echo $foo{3} . "\n"; // <-- warning
$foo = "foo"; echo @$foo{3}. "\n"; // <-- still warning
?>
The last line should not emit a warning.
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Tue Oct 28 11:00:01 2025 UTC |
It's not a bug, $foo{3}. "\n" is done before the @, so that displays the error. so I'm closing this, this works BTW: $foo = "foo"; echo @($foo{3}. "\n"); DerickIt's an engine thing, and can really not be fixed. The accessing of the {3} is done after the END_SILENCE op at the CONCAT op. I'll mark it as suspended for now.This error, in latest PHP versions, only occurs when your trying to treat a plain variable as an array. In most occasions you can get round this by adding in an isArray check before you try to use the var as an array. For example; Problem: if (isset($parameter['align'])) { echo 'moo'; } // error: Uninitialized string offset Solution: if (!isarray($parameter)) { $parameter = array(); } if (isset($parameter['align'])) { echo 'moo'; } So your basically setting an empty array in place of an empty variable.