Skip to content

PHP Return Statement

Syntax

The return statement in PHP is used to exit a function and optionally return a value to the caller.

function functionName() {
// Code to execute
return $value;
}
// Call function
functionName();

Example

function sayHello() {
return 'Hello World';
}
echo sayHello();
// Output: Hello World