Search code examples
phptry-catchnotation

PHP try-catch supports short notation?


Is this legal? Not near my work computer so can't test

try
    someClass::someStaticFunction();
catch(Exception $e)
    $e->getMessage();

Specifically the lack of brackets, similar to an if-else statement

if(someBool)
    someClass::someStaticFunction();
else
    someClass::someOtherFunction(); 

Cheers!


Solution

  • No, doesn't seem like it works.

    Check my example here: http://codepad.org/BpSBiPDY