Laravel 5.1
- 在bootstrap下新建common.php文件,在这里写入自定义函数。
- 在bootstrap/autoload.php中末尾处添加如下语句:
$compiledPath = __DIR__.'/common.php';
if (file_exists($compiledPath))
{
require $compiledPath;
}
ThinkPHP 5.0
在application/common.php中直接写入自定义函数即可。
$compiledPath = __DIR__.'/common.php';
if (file_exists($compiledPath))
{
require $compiledPath;
}
在application/common.php中直接写入自定义函数即可。