Req #68584 [Opn->Sus]: I hope "unset" keyword can be used after "or"
| From: | stas@php.net | Date: | Sat, 05 Aug 2017 04:54:11 +0000 |
| Subject: | Req #68584 [Opn->Sus]: I hope "unset" keyword can be used after "or" | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-210517@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: stas@php.net
Reported by: 523826219 at qq dot com
Summary: I hope "unset" keyword can be used after "or"
-Status: Open
+Status: Suspended
Type: Feature/Change Request
Package: Scripting Engine problem
Operating System: Windows&&Linux
PHP Version: Irrelevant
Block user comment: N
Private report: N
New Comment:
Thank you for your interest in PHP and for submitting a feature request. Please be aware that due to
the magnitude of change this request requires, it would be necessary to discuss it on PHP Internals
list (internals@lists.php.net) as an RFC. Please read the guide about creating RFCs here:
https://wiki.php.net/rfc/howto
If you haven't had experience with writing RFCs before, it is advised to seek guidance on the
Internals list (http://php.net/mailing-lists.php) and/or solicit help from one of the experienced
developers.
Please to not consider this comment as a negative view on the merits of your proposal - every
proposal which requires changes of certain magnitude, even the very successful and widely supported
ones, must be done through the RFC process. This helps make the process predictable, transparent and
accessible to all developers.
Previous Comments:
------------------------------------------------------------------------
[2015-06-08 19:54:17] cmb@php.net
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]);
------------------------------------------------------------------------
[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