Skip to content
PHP Logo

How can PHP functions be checked for execution status?

To check the execution status of PHP functions, you can use the `return` statement to return a value indicating success or failure. You can then use this return value to determine if the function executed successfully or encountered an error.

php
function myFunction() {
    // perform some operations
    if (/* condition for success */) {
        return true; // return true for success
    } else {
        return false; // return false for failure
    }
}

// Check the execution status of the function
if (myFunction()) {
    echo "Function executed successfully";
} else {
    echo "Function encountered an error";
}