我不明白为什么运行PHP 7.2.9的机器会出现这个错误:
致命错误:无法声明类Error,因为该名称已在第3行的controllers\error.php中使用
我有一个名为的文件controllers/error.php,其中包含:
<?php
class Error {
function __construct() {
echo 'Error: 404 not found the file.';
}
}
Run Code Online (Sandbox Code Playgroud)
同时,我有一个名为的文件/index.php,其中包含:
require "controllers/error.php";
$controller = new Error;
Run Code Online (Sandbox Code Playgroud)
即使我require改为require_once "controllers/error.php",它仍然保持报告相同的消息.
php ×1