On 23 September 2016 at 17:40, Rowan Collins <rowan.coll...@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

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to