Edit report at https://bugs.php.net/bug.php?id=72563&edit=1
ID: 72563
Updated by: requinix@php.net
Reported by: security at nsa dot gov
Summary: @unset() return error
Status: Open
Type: Bug
-Package: PHP Language Specification
+Package: Scripting Engine problem
Operating System: Windows
PHP Version: 7.0.8
Block user comment: N
Private report: N
New Comment:
@ is only allowed with expressions and unset is considered a statement, like control structures and
return.
It is possible for unset(expr) to raise an error <https://3v4l.org/idvWY>, and it looks like @ is implemented as
a begin/execute/end sequence rather than a "silence the next expression" operation, so
maybe @ could be promoted to support statements too? Code like
@foreach ($array as $var) {
looks a bit odd, but I can't think of any reason why it should specifically not be supported.
(Putting aside the general "don't use the error suppression operator" advice, that
is.)
Previous Comments:
------------------------------------------------------------------------
[2016-07-08 05:50:17] security at nsa dot gov
Description:
------------
If I use @ to supress error, PHP failed to parse @unset.
Test script:
---------------
<?php
$a='aaa';
@unset($a);
?>
Expected result:
----------------
No error
Actual result:
--------------
Erros parsing
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=72563&edit=1