PHP switch statements for mixing scalars and objects

1 day ago 1
ARTICLE AD BOX

Is it considered bad practice if you use PHP's switch statement for mixing scalars and objects?

For example:

$myIntegerOrComplexObject = getIntOrObject(); switch( $myIntegerOrComplexObject ) { case 1: echo "blub"; break; case 2: echo "bla"; break; default: echo "This is probably an object or a int other than 1 & 2"; }

Can I expect this behavior to be safe? Or should I expect unwanted side effects?

Thank you very much in advance!

Read Entire Article