Re: RFC: Strict comparisons
| From: | Dan Ackroyd | Date: | Fri, 23 Sep 2016 22:14:37 +0000 |
| Subject: | Re: RFC: Strict comparisons | ||
| References: | 1 2 3 4 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-96124@lists.php.net to get a copy of this message | ||
On 23 September 2016 at 17:40, Rowan Collins <rowan.collins@gmail.com> wrote:
>
> I've been pondering an idea for ages of a generalised syntax for switch to
> specify an operator to use, so you'd do something like this:
That's technically possible already:
function foobar($foo)
{
switch (true) {
case $foo === '1':
echo "close but no cigar\n";
break;
case $foo === 1:
echo "identical\n";
break;
case $foo == 1:
echo "why you do this\n";
break;
}
}
foobar(1);
foobar("1 apple");
It's just a little bit icky.
cheers
Dan