使用PHP进行类加载访问-是否可以从两个不同的资源加载相同的类?
我只是想知道,实际上我决定走另一条路。 我创建了一个文件使用PHP进行类加载访问-是否可以从两个不同的资源加载相同的类?,php,joomla,Php,Joomla,我只是想知道,实际上我决定走另一条路。 我创建了一个文件 C:\somefolder\templates\mytemplate\joomlaoverwrites\libraries\joomla\document\html\renderer\head.php 它将覆盖joomla库文件: C:\somefolder\libraries\joomla\document\html\renderer\head.php 我通过使用 require_once(__DIR_.'/joomlaoverwrit
C:\somefolder\templates\mytemplate\joomlaoverwrites\libraries\joomla\document\html\renderer\head.php
它将覆盖joomla库文件:
C:\somefolder\libraries\joomla\document\html\renderer\head.php
我通过使用
require_once(__DIR_.'/joomlaoverwrites/libraries/joomla/document/html/renderer/head.php')代码>
在模板的my index.php中
这确实有效
我现在想做的是将我的文件用作包装类,并在返回答案之前将我的更改偷偷地放入其中。例如:
public function fetchHead($document)
{
$joomlasOriginalHead = callOriginalFunctionFetchHeadFromTheJoomlaImplementation();
//do my changes to joomlas original answer and return that
}
例如,从覆盖开始,我想调用原始文件。这可能吗?类需要扩展父类,然后可以使用$this->methodName()或parent::methodName()访问所有父类方法。对,我为什么没有想到这一点