0

所以我在 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).

真诚感谢您的帮助。非常感谢!

4

1 回答 1

0

改用include_once函数。

http://php.net/manual/en/function.include-once.php

于 2015-02-13T09:42:10.843 回答