【发布时间】:2012-09-19 06:36:21
【问题描述】:
我对 PHP 的 extends 有疑问。我的代码在page.class.php:
<?php
require_once ('globals.class.php');
require_once ('Smarty.class.php');
class CPage extends Smarty
{
.
.
.
在Smarty.class.php 中,类名是Smarty。
所以我不知道为什么会出现这个错误:
致命错误:在第 6 行的 C:\xampp\htdocs\blog\www\classes\page.class.php 中找不到类“Smarty”
【问题讨论】:
-
你确定
Smarty.class.php不为空吗? -
如果 Smarty 使用命名空间,你应该声明 class CPage extends \namespace\of\Smarty
-
你能做一个
echo (defined('SMARTY_DIR') ? 'Yes' : 'No');看看Smarty.class.php 是否被正确处理了吗?除非没有调用 require_once 或调用“错误”文件(例如,正如 Mihai 所说,一个空文件),否则 hte 代码没有理由失败。 -
echo (defined('SMARTY_DIR') ? 'Yes' : 'No'); -> 答案是“否”.. Smarty.class.php 不是空的,该类将在那里定义 100%。我认为答案应该是“是”@Robbie 还是?怎么了?! ://