【发布时间】:2011-12-24 11:37:55
【问题描述】:
首先,我使用function_exists 来检查我的函数之前是否已声明但没有帮助。
这是我的代码:
if ( !function_exists('something') ) {
function something($params) {
[..]
}
}
当我进入该函数两次声明的页面时,出现以下错误:Fatal error: Cannot redeclare something() (previously declared in [..])
所以问题是,我如何检查该函数是否已经存在,如果它存在跳过加载它两次?
【问题讨论】:
-
只需在您的 php 代码中使用 include_once 或 require_once。
-
您是如何将函数声明两次的?如果是因为包含,您应该使用
include_once()