Php 严格标准:在中不应静态调用非静态方法MenuHelper::getArticleByID()
刚开始学习joomla,在php方面有点差劲,我不知道如何进行非静态调用。 获取此错误:严格标准:不应在中静态调用非静态方法MenuHelper::getArticleByID()Php 严格标准:在中不应静态调用非静态方法MenuHelper::getArticleByID(),php,joomla,Php,Joomla,刚开始学习joomla,在php方面有点差劲,我不知道如何进行非静态调用。 获取此错误:严格标准:不应在中静态调用非静态方法MenuHelper::getArticleByID() <?php defined('_JEXEC') or die; $base = JURI::base(true); $menu = JFactory::getApplication()->getMenu(); $item = $menu->getMenu(); include __DIR__
<?php
defined('_JEXEC') or die;
$base = JURI::base(true);
$menu = JFactory::getApplication()->getMenu();
$item = $menu->getMenu();
include __DIR__ . '/helper.php';
?>
<div class="container">
<div class="item support">
<div class="content">
<div class="title">
<span class="name"><a href="<?php echo $item[106]->flink; ?>" class="rumble"><?php echo $item[106]->title; ?></a></span>
<span class="icon"><img src="<?php echo $base; ?>/templates/tehnos/images/man.png" alt="" /></span>
</div>
<div class="text">
<h3><?php echo MenuHelper::getArticleByID(2)->title; ?></h3>
<?php echo MenuHelper::getArticleByID(2)->introtext; ?>
</div>
</div>
</div>
<div class="item center">
<div class="content">
<div class="title">+
<span class="name"><a href="<?php echo $item[107]->flink; ?>" class="rumble"><?php echo $item[107]->title; ?></a></span>
<span class="icon"><img src="<?php echo $base; ?>/templates/tehnos/images/man.png" alt="" /></span>
</div>
<div class="text">
<h3><?php echo MenuHelper::getArticleByID(3)->title; ?></h3>
<?php echo MenuHelper::getArticleByID(3)->introtext; ?>
</div>
</div>
</div>
<div class="item service">
<div class="content">
<div class="title">
<span class="name"><a href="<?php echo $item[108]->flink; ?>" class="rumble"><?php echo $item[108]->title; ?></a></span>
<span class="icon"><img src="<?php echo $base; ?>/templates/tehnos/images/man.png" alt="" /></span>
</div>
<div class="text">
<h3><?php echo MenuHelper::getArticleByID(4)->title; ?></h3>
<?php echo MenuHelper::getArticleByID(4)->introtext; ?>
</div>
</div>
</div>
<div class="item events">
<div class="content">
<div class="title">
<span class="name"><a href="<?php echo $item[109]->flink; ?>" class="rumble"><?php echo $item[109]->title; ?></a></span>
<span class="icon"><img src="<?php echo $base; ?>/templates/tehnos/images/man.png" alt="" /></span>
</div>
<div class="text">
<?php echo MenuHelper::getArticleByID(5)->introtext; ?>
</div>
</div>
</div>
<div class="item standards">
<div class="content">
<div class="title">
<span class="name"><a href="<?php echo $item[110]->flink; ?>" class="rumble"><?php echo $item[110]->title; ?></a></span>
<span class="icon"><img src="<?php echo $base; ?>/templates/tehnos/images/man.png" alt="" /></span>
</div>
<div class="circle"></div>
<div class="text">
<?php echo MenuHelper::getArticleByID(6)->introtext; ?>
</div>
</div>
</div>
/templates/technos/images/man.png“alt=”“/>
+
/templates/technos/images/man.png“alt=”“/>
/templates/technos/images/man.png“alt=”“/>
/templates/technos/images/man.png“alt=”“/>
/templates/technos/images/man.png“alt=”“/>
谢谢您的时间!错误消息已经告诉您,MenuHelper中的方法似乎没有定义为公共静态函数getArticleByID(…) public static function getArticleByID (...) 因此,您可以做的是在include之后获取MenuHelper的一个实例 $menuHelper = new MenuHelper(); $menuHelper=新menuHelper(); 然后更换 MenuHelper::getArticleByID()
MenuHelper::getArticleByID(),代码中有$MenuHelper->getArticleByID()。现在您应该删除错误消息。错误消息已经告诉您,MenuHelper中的方法似乎没有定义为公共的静态的函数getArticleByID(…) public static function getArticleByID (...) 因此,您可以做的是在include之后获取MenuHelper的一个实例 $menuHelper = new MenuHelper(); $menuHelper=新menuHelper(); 然后更换 MenuHelper::getArticleByID() MenuHelper::getArticleByID(),并在代码中添加$MenuHelper->getArticleByID()。现在您应该删除错误消息。非常感谢@TheColaKid谢谢@TheColaKid