Bruce Bruce - 1 year ago 54
PHP Question

How to do an if statement on a function in PHP?

I just realized that you can't just use an if statement on a function, for example this doesn't work:

function sayHello()
echo "Hello World";

echo "Function Worked";
echo "Function Failed";

I also saw that a function can't be put as the value of a variable. So how can I do an if statement to check if a function has executed properly and display it to the browser?

Answer Source

It's not working since sayHello() doesn't return anything place return true in there or something.