1. Use function start;
2. The function name can start with a letter or an underscore;
3. The function body must be within curly braces ;
1 <? PHP 2 3 function A_b () { 4 5 Echo "hello!!" ; 6 7 } 8 9a_b (); Ten ?>
4.php function can have no parameters, can also have more than one parameter, if there are multiple parameters to be separated by commas ;
5. The parameter is similar to a variable, to start with $ ;
1 <? PHP 2 3 function a_b ($a,$b) {4 echo$a+$b ; 5 }67 a_b; 8 9 ?>
6. The return keyword allows the function to return a value;
<? PHP function a_b ($a,$b) { return$a+$b ;} $h _b = A_b; Echo $h _b ;? >
7. Function cannot return multiple values;
8. The built-in function is the function that PHP itself supports by default;
9. use in PHP function_exists To determine whether a function exists;
1<?PHP2 3 functionA_b () {4 Echo"Hello";5 }6 7 if(function_exists(' A_b ')) {8 9 Echo' Yes ';Ten } One A?>
10. The function will not be executed immediately when the page is loaded;
11. Functions are executed only when they are called;
PHP Notes-functions (1)