You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
21 lines
551 B
21 lines
551 B
<?php
|
|
/**
|
|
* 回调函数就是吧函数作为参数,传入到另外的函数中,然后被调用
|
|
* 回调函数的本质是可变函数
|
|
*/
|
|
|
|
//1.定义一个函数
|
|
function eat(){
|
|
echo "eating";
|
|
}
|
|
|
|
//2.定义另外一个函数
|
|
function ican($do){
|
|
$do();
|
|
echo "\n";
|
|
}
|
|
|
|
//3. 把第一个函数作为第二个函数的参数
|
|
//实际上就是$do()就是可变函数,变量$do等于函数eat()
|
|
//函数eat,作为ican函数的参数,在ican()被调用
|
|
ican("eat");
|