所以我在 mylibfunctions.php 中使用 carbon api,当然也在页面本身上使用。PHP 不会让你包含一个文件两次,那么我该如何在 mylibfunctions.php 中包含/引用该文件呢?
index.php:
<?php
include('session-info.php');
include('phpsqlinfo_dbinfo.php');
include('carbon.php');
use Carbon\Carbon;
include('mylibfunctions.php'); //using carbon functions here
不包括 mylibfuncitons 上的 carbon API 文件会返回此错误:
Fatal error: Class 'Carbon' not found in /var/www/mylibfunctions.php on line 4
并包括他们返回类似:
cannot require blah blah blah more than once. (not exact error message).
真诚感谢您的帮助。非常感谢!