Skip to content

PHP Parameters

Syntax

Parameters in PHP are used to pass values to functions, allowing customization of their behavior. Parameters can be optional or required.

function functionName($param1, $param2) {
// Code to execute using $param1 and $param2
}
// Call function
functionName($arg1, $arg2);

Example

function multiply($a, $b) {
return $a * $b;
}
$result = multiply(4, 5);
echo $result; // Output: 20