Edit report at https://bugs.php.net/bug.php?id=64248&edit=1

 ID:                 64248
 Updated by:         johan...@php.net
 Reported by:        bobwei9 at hotmail dot com
 Summary:            Strange parse error when using language construct in
                     for
-Status:             Open
+Status:             Not a bug
 Type:               Bug
 Package:            Scripting Engine problem
 Operating System:   Irrelevant (OS X 10.8)
 PHP Version:        master-Git-2013-02-19 (Git)
 Block user comment: N
 Private report:     N

 New Comment:

Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

unset() jsut as many other language constructs has no return value and is no 
expression. for expects expressions. This construct makes sense only in very 
few cases, even though it might make the language a tiny bit simpler (less 
exceptions) it is not worth changing the language ... (changing language has 
effects for the whole environment, from IDEs to code analyzers, to ...)


Previous Comments:
------------------------------------------------------------------------
[2013-02-19 21:05:21] bobwei9 at hotmail dot com

Oops, the expected result should be a notice and $max should be 'A' in the test 
script...

------------------------------------------------------------------------
[2013-02-19 21:03:57] bobwei9 at hotmail dot com

Description:
------------
For example unsetting a var in the third part of a for-loop throws an E_PARSE 
error.

Test script:
---------------
php -r '
$A = [1];
$B = [1,7];
$max = 'B';
for ($i='A'; ++$i<$max; unset($$i))
var_dump($$i);'


Expected result:
----------------
array(1) {
  [0]=>
  int(1)
}
array(2) {
  [0]=>
  int(1)
  [1]=>
  int(7)
}

Actual result:
--------------
PHP Parse error:  syntax error, unexpected 'unset' (T_UNSET), expecting ')' in 
Command line code on line 1


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



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

Reply via email to