Req #68584 [Opn]: I hope "unset" keyword can be used after "or"

From: Date: Mon, 08 Jun 2015 19:54:17 +0000
Subject: Req #68584 [Opn]: I hope "unset" keyword can be used after "or"
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-193212@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=68584&edit=1 ID: 68584 Updated by: cmb@php.net Reported by: 523826219 at qq dot com Summary: I hope "unset" keyword can be used after "or" Status: Open Type: Feature/Change Request Package: Scripting Engine problem Operating System: Windows&&Linux PHP Version: Irrelevant Block user comment: N Private report: N New Comment: The unset language construct is actually a statement (what should be explicitly documented). Therefore unset can't be used where an expression is expected. It might be reasonable to change this, but then again, you can simply change your code: if (false!==($targetKey=array_search(3,$myDS))) unset($myDS[$targetKey]); Previous Comments: ------------------------------------------------------------------------ [2014-12-10 08:24:47] chx@php.net The specification describes the current behavior and this is a feature request against I guess PHP 7. ------------------------------------------------------------------------ [2014-12-10 07:10:19] 523826219 at qq dot com Description: ------------ <?php $myDS=array(1,2,3); false===($targetKey=array_search(3,$myDS)) or var_dump($targetKey); // outputs:2 false===($targetKey=array_search(3,$myDS)) or unset($myDS[$targetKey]); // Fail:this is a syntax error!(Actually I just want to remove the target element with specified value from the array-$myDS,but it does not work!) Test script: --------------- <?php $myDS=array(1,2,3); false===($targetKey=array_search(3,$myDS)) or var_dump($targetKey); // outputs:2 false===($targetKey=array_search(3,$myDS)) or unset($myDS[$targetKey]); // Fail:this is a syntax error!(Actually I just want to remove the target element with specified value from the array-$myDS,but it does not work!) =>So ,I hope "unset" keyword can be used after "or" keyword,Thank you ! Expected result: ---------------- Actually "exit" keyword can be used after "or" keyword,why not "unset"? for example: !defined('IN_MANAGE') or exit('no access for this site!'); // works successfully I hope "unset" keyword can be used after "or" keyword,Thank you ! for example: !isset($somekey) or unset($myDS[$somekey]); Actual result: -------------- Actually "exit" keyword can be used after "or" keyword,why not "unset"? for example: !defined('IN_MANAGE') or exit('no access for this site!'); // works successfully I hope "unset" keyword can be used after "or" keyword,Thank you ! for example: !isset($somekey) or unset($myDS[$somekey]); ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=68584&edit=1

« previous php.bugs (#193212) next »