将扩展类拆分到不同的文件中(php)
Szenario
我得到了一个类作为抽象类的扩展。抽象类加载我的文件&扩展及其方法(链接到抽象类的pastebin)。
这在我的扩展类中被调用,如下所示(缩短和简化 - 拼写错误仅出现在 Q 代码中):
class Pagination extends Pagination_Base
{
function __construct()
{
// loads the file "first.class.php" in the abstract class
parent::load_file( 'first' );
// stores the class as object in the abstract class, so we can access the methods and properties
parent::load_extension( new oxoFirst() );
}
}
问题/问题
现在我收到错误“无法重新声明类 {$classname}” 。
我想使用我的抽象类,但仍然能够将包含扩展名的类移动到单独的文件中。有什么办法可以做到这一点吗?
提前致谢!
Szenario
I got a class as extend of an abstract class. The abstract class loads my files & extensions with their methods (link to pastebin for abstract class).
This gets called in my extends class like this (shortened & simplified - typos are only here at the Q-code):
class Pagination extends Pagination_Base
{
function __construct()
{
// loads the file "first.class.php" in the abstract class
parent::load_file( 'first' );
// stores the class as object in the abstract class, so we can access the methods and properties
parent::load_extension( new oxoFirst() );
}
}
Problem/Question
Now i got the error "Cannot redeclare class {$classname}".
I want to use my abstract class but still be able to move classes that contain extensions into separate files. Is there any way to do this?
Thanks in advance!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在
load_file
函数中使用include_once
而不是include
。Use
include_once
instead ofinclude
in theload_file
function.