I've seen before in scripts something like this:
So in other words, if doSomething() fails, doSomethingElse () will execute.
I've tried to do the same thing:
The problem is, it *always* executes doSomethingElse (), regardless of whether an exception was thrown or not. Any help?
And yes, I know about "try...catc h"; I just like to have a one-liner alternative.
Code:
doSomething() or doSomethingElse()
I've tried to do the same thing:
Code:
<?php
function doSomething($x)
{
if ( $x != 0 )
{
throw new Exception('error!');
}
}
function doSomethingElse()
{
print 'something else';
}
doSomething(0) or doSomethingElse();
?>
And yes, I know about "try...catc h"; I just like to have a one-liner alternative.
Comment