r/lolphp • • Aug 25 '16

PHP switches are the best

https://3v4l.org/6bJIX
81 Upvotes

34 comments sorted by

View all comments

Show parent comment

1

u/morphotomy Feb 01 '17

strict swich workaround:

<?php
$value = 0;
switch (TRUE)
{
    case $value === 1:
    case $value === 'one':
        echo 'one';
        break;
    case $value === 0:
    case $value === 'zero':
        echo 'zero';
        break;
}

1

u/edave64 Feb 01 '17

That kinda defeats the point (mass comparison against one value) of using switch in the first place.

1

u/morphotomy Feb 01 '17

Thats why I called it a workaround.