我正在使用XAMPP,我收到了这个错误
Fatal error: Cannot redeclare example() (previously declared in
Run Code Online (Sandbox Code Playgroud)
我理解这个错误,这意味着该函数已在其他地方声明.
在我的www.example.com/cores/functions.php中,我正在声明这个功能
function example(){
$site_name = "Example CMS";
return $site_name;
}
Run Code Online (Sandbox Code Playgroud)
该功能将执行什么操作,它将保留默认的示例CMS.但是,如果有人宣称在同一个函数www.example.com/functions.php,那么系统应该皮卡这是在www.example.com/functions.php,不应该在挑www.example.com/cores/functions .PHP
在我的www.example.com/functions.php中
function example(){
$site_name = "My CMS";
return $site_name;
}
Run Code Online (Sandbox Code Playgroud)
那可能吗?
是的,但前提是您首先要包含www.example.com/functions.php.然后在你的cores/functions.php中执行以下操作:
if (!function_exists('example')) {
function example(){
$site_name = "Example CMS";
return $site_name;
}
}
Run Code Online (Sandbox Code Playgroud)