I have a problem with the extends
of PHP. My code in the page.class.php
:
<?php
require_once ('globals.class.php');
require_once ('Smarty.class.php');
class CPage extends Smarty
{
.
.
.
In the Smarty.class.php
the class name is Smarty
.
So I don't know why I get this error:
Fatal error: Class 'Smarty' not found in C:\\xampp\\htdocs\\blog\\www\\classes\\page.class.php on line 6
This is more a comment than an actual answer:
As you use require
I assume that the Smarty
class has been defined.
So you are probably using namespaces, which would require you to use
that specific class or provide a fully qualified classname (FQCN) instead:
class CPage extends \Smarty
^- Smarty is in the global namespace in this example
Otherwise use the class on top:
Use \Smarty;
to import it into your current namespace.
The answer is with the pre-condition that the Smarty
class you refer to is in the global namespace. I'm not fluent with Smarty so I do not know if it has it's own namespace yet, and if so, which one it is. So the concrete FQCN might vary.
See as well:
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.