|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2012-03-27 13:45 UTC] asserte at gmail dot com
Description:
------------
isset() && unset()
PHP Parse error: syntax error, unexpected 'unset' (T_UNSET), expecting ')' in
/tmp/isset.php on line 4
Tested on PHP 5.4.0-3 (cli) (built: Mar 22 2012 07:59:57)
Test script:
---------------
$> cat /tmp/isset.php
1 <?php
2
3 $entity = array('id' => 1, 'name' => 'example');
4 isset( $entity['id'] ) && unset( $entity['id'] );
$> php /tmp/isset.php
PHP Parse error: syntax error, unexpected 'unset' (T_UNSET), expecting ')' in /tmp/isset.php on line 3
Expected result:
----------------
unset should works.
Patchesbug61529.phpt (last revision 2012-03-29 12:51 UTC by laruence@php.net)bug61529.patch (last revision 2012-03-29 12:49 UTC by laruence@php.net) Pull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Oct 30 15:00:01 2025 UTC |
I just hit this bug trying to unset a variable in a for loop, like this: <?php for( ; ; unset($i)) { if($someCondition) { $i = 42; } if(isset($i)) { doSomething(); } else { doSomethingElse(); } } I understand why this currently fails and obviously there are workarounds, but intuitively unset should work in the third expression of a for loop.