【发布时间】:2018-08-16 11:14:04
【问题描述】:
我在运行 php 脚本时遇到Registry has a deprecated constructorError。它在第 261 行显示错误。转到该行我有以下代码。如何避免此错误。
class Registry {
function Registry() {
define("CWD", ($getcwd = getcwd() ? $getcwd : "."));
$config = array();
include INCLUDES . "config.php";
if (sizeof($config) == 0) {
if (file_exists(INCLUDES . "config.php")) {
exit( "<div style=\"border: 1px dashed #cc0000;font-family:Tahoma;background-color:#FBEEEB;width:100%;padding:10px;color:#cc0000;\"><strong>Welcome to EvolutionScript 5.1 FULL</strong><a></a><br>Before you can begin using EvolutionScript you need to perform the installation procedure. <a href=\"" . (file_exists( "install/install.php" ) ? "" : "../") . "install/install.php\" style=\"color:#000;\">Click here to begin ...</a><br></div>" );
}
else {
exit("<br /><br /><strong>Configuration</strong>: includes/config.php does not exist. Please fill out the data in config.php.new and rename it to config.php");
}
}
$this->config = $config;
define("TABLE_PREFIX", trim($this->config['Database']['tableprefix']));
define("COOKIE_PREFIX", (empty($this->config['Misc']['cookieprefix']) ? "ptc" : $this->config['Misc']['cookieprefix']) . "_");
}
}
【问题讨论】:
-
使用
__construct()而不是Registry() -
我认为你应该使用
function __construct() {}而不是function Registry() {} -
类注册表{
-
使用函数 __construct() 页面不工作
标签: php class constructor