In PHP, you can use the return statement to exit a function and return a value if needed. The return statement not only returns a value but also exits the function immediately.
Source code viewer
function myFunction() { // Some code here if ($someCondition) { // Break out of the function return $someValue; } // More code here // If the condition is not met, the function continues here } // Call the function $result = myFunction();Programming Language: PHP