Req #76140 [Opn->Sus]: Allow multiple comparisons in expressions

From: Date: Fri, 23 Mar 2018 08:11:40 +0000
Subject: Req #76140 [Opn->Sus]: Allow multiple comparisons in expressions
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-214446@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=76140&edit=1 ID: 76140 Updated by: requinix@php.net Reported by: valentiny510 at gmail dot com Summary: Allow multiple comparisons in expressions -Status: Open +Status: Suspended Type: Feature/Change Request Package: Variables related Operating System: Windows PHP Version: 7.2.3 Block user comment: N Private report: N New Comment: That's already valid code. There would have to be a new syntax for this. But it won't happen in this bug reporting tool because this is too significant of an addition. It would have to go through the RFC process, which begins by talking about this on the internals mailing list. https://wiki.php.net/rfc/howto Previous Comments: ------------------------------------------------------------------------ [2018-03-23 02:35:46] valentiny510 at gmail dot com Description: ------------ Currently to compare if a variable have some (?:exact)? value we need to use arrays or enumerate a list of all values + the variable name itself, Ex: $a = true; if ($a === 'a' || $a === 'b' || $a === 'c') # etc... print 'true'; else print 'false'; IMHO will be very very handy if we can evaluate them all in a single expression like this: if ($a === ('a'||'b'||'c') # ... is much cleaner and easier to read and understand the whole sentence Test script: --------------- $a = 'a'; if ($a === ('a'||'b'||'c')) print 'true'; else print 'false'; Expected result: ---------------- true Actual result: -------------- false ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=76140&edit=1

« previous php.bugs (#214446) next »