//方法定义
app/common.php 文件中定义公共方法
function say_hello($name,$age) { echo "My name is ".$name; echo "I'm ".$age."ten years old"; }
//方法调用
在 app 中的模块的方法里可以直接调用app/common.php中的方法
<?php namespace app\index\controller; use think\Controller class Index extends Controller{ public function index() { $name = "张三"; $age = "20"; say_hello($name,$age)//调用say_hello,并传入两个参数; } }