When I call a function inside try block before defining. it gives me fatal error
What I was trying to do is this
try {
echo someFunction();
fu
When a function is defined in a conditional manner it's definition must be processed prior to being called. Just switch the echo and function like below.
try {
function someFunction()
{
return 'hello';
}
echo someFunction();
} catch (Exception $e ){
return $e->getMessage();
}
http://php.net/manual/en/functions.user-defined.php