PHP 无法重新声明 class 由函数引起

PHP Cannot redeclare class caused by a function

我收到无法重新声明 class 错误。这是导致错误

的 class 文件
<?
class siteLoader{


public $view;
protected $page;
//vars for render head function
protected $arraySize;
protected $counter;

public function __construct(){}
//renders the view for the site
public function renderView($view){
    $this->view = $view;
    return "view/{$view}.view.php";
}
//renders the head part of the site
//public function renderHead($head){
public function renderHead($charset,$title,$description,$keywords,$applicationName,$css){
    //$this->head = $head;
    $this->charset = $charset;
    $this->title = $title;
    $this->description = $description;
    $this->keywords = $keywords;
    $this->applicationName = $applicationName;
    $this->css = $css;
    $arraySize = count($this->css, COUNT_RECURSIVE);
    $counter =0;
    echo '<head>
        <meta charset="'.$charset.'">
        <meta application-name="'.$applicationName.'">
        <meta keywords="'.$keywords.'">
        <meta description="'.$description.'">
        <title>'.$title.'</title>
    ';
    do{
        echo '<link type="text/css" rel="stylesheet" href="css/'.$this->css[$counter].'.css">';
        $counter++;
        }while($counter != $arraySize);
    echo '</head>';
    return 0;
}


}
?>

只有当我调用 renderView() 函数时才会发生错误。 下面是我调用 class 和函数的索引。

<!DOCTYPE html>
<html>
<?
if(!class_exists('siteLoader'))
{
require_once('/classes/html.class.php');
}

//$head = new html;
$html = new siteLoader;
$viewrender = new siteLoader;

$charset = "utf-8";
$title = "musicDB";
$description = "Not made yet";
$keywords = "music,DB,rock,Database,etc";
$applicationName = "Music DataBase";
$css = array('style');
$view = "main";
     $html->renderHead($charset,$title,$description,$keywords,$applicationName,$css);
include $viewrender->renderView($view);

?>
</html>

如上所示,我使用 require_once 并检查 class 是否已加载。 问题可能出在 renderView 函数中,因为当我不使用该函数时,一切正常。

这一行包括 $viewrender->renderView($view); main.view.php 中的 class 名称是什么 查看 class 名称是否为 siteloader