I have been trying throw new exception in my php function, but it does not echo the error the message. I could have used the regular echo instead, but I really want to see the difference. please tell me what's wrong with this code.
function searchMovie($movieName){
if (!isset($movieName))
throw new Exception('missing movie name');
//execute
//return something here
}
//call the function
echo searchMovie('iron man'); //this gives a result.
echo searchMovie(); //this does not echo the 'missing movie name'
Thanks. Any help for a noob like me will be really appreciated.
Should be like this
function searchMovie($movieName){
if (!isset($movieName))
{
throw new Exception('missing movie name');
//execute
//return something here
}
}