# 函数 * * * * * Table of Contents 1. 用户自定义函数 2. 函数的参数 3. 返回值 4. 可变函数 5. 内部(内置)函数 6. 匿名函数 * * * * * **用户自定义函数** ~~~ function foo ( $arg_1 , $arg_2 , /* ..., */ $arg_n ) { echo "Example function.\n" ; return $retval ; } ~~~ **return** ~~~ function square ( $num ) { return $num * $num ; } echo square ( 4 ); // outputs '16'. ~~~ **匿名函数** ~~~ $greet = function( $name ) { printf ( "Hello %s\r\n" , $name ); }; $greet ( 'World' ); $greet ( 'PHP' ); ~~~