```
# 定义函数
function simpleFunction() {
echo 'Hello World';
}
simpleFunction();
function sayHello($name='aa') {
echo "hello $name";
echo 'hello'.$name;
}
sayHello('xuxu');
sayHello();
# 有参有返回值
function addNumbers($num1, $num2) {
# echo $num1 + $num2;
return $num1 + $num2;
}
echo addNumbers(2, 3);
# 函数传引用
$myNum = 10;
// php 函数内不会改变传入的外界值
function addFive($num) {
$num += 5;
}
// &会改变传入的外界值
function addTen(&$num) {
$num += 10;
}
addFive($myNum);
addTen($myNum);
echo "Value: $myNum"; // 10
```