Lesson 6 of 8
Functions
Functions are reusable blocks of code. Define them with the function keyword. You can return values and accept parameters.
PHP
<?php
function greet($name) {
return "Hello, " . $name;
}
function add($a, $b) {
return $a + $b;
}
echo greet("Ali"); // "Hello, Ali"
echo add(3, 4); // 7
?>