php - Joomla 3.8 与 PHP 7 问题

标签 php web joomla

我的网站目前正在从 PHP 5.6 强制过渡到 7.1(或 7.2,两者都是一个选项)。我有两个网站,一个工作正常,但另一个无法在 7.1 或 .2 上运行。

我收到以下错误消息:

[Thu Oct 25 09:25:21.985120 2018] [:error] [pid 12006] PHP Deprecated: Non-static method Joomla\\CMS\\Application\\CMSApplication::getMenu() should not be called statically, assuming $this from incompatible context in /home/public/sites/www.modderaandebanden.nl/libraries/src/Application/SiteApplication.php on line 275
[Thu Oct 25 09:25:21.985130 2018] [:error] [pid 12006] PHP Strict Standards: Only variables should be assigned by reference in /home/public/sites/www.modderaandebanden.nl/templates/siteground-j16-1/templates.php on line 15

我在所有页面上都遇到问题(它到处都使用相同的模板)。这是我打开当前使用的 Siteground J16-1 模板的 templates.php 时得到的结果:

<?if( $sg == 'banner' ):?>

    <?php if (JRequest::getVar('view') == 'frontpage'):?>

    <!-- SIDE BEGIN --><!-- SIDE END -->

    <?php endif?>

<?else:?>

    <?php echo $app->getCfg('sitename'); ?>, Powered by <a href="http://joomla.org/" class="sgfooter" target="_blank">Joomla!</a>



    <?php $menu = &JSite::getMenu();

    if ($menu->getActive() == $menu->getDefault()) :?>

        <!-- FOOTER BEGIN --><a href="http://www.siteground.com/cpanel-hosting.htm" target="_blank">Hosting with cPanel by SiteGround</a><!-- FOOTER END -->

    <?php endif ?>



<?endif;?>

请告诉我这是否可以澄清问题。请原谅我的笨蛋...:-D

www.modderaandebanden.nl 是我的网站。

谁能告诉我这是怎么回事?该模板是否不适合 PHP 7 使用?

提前致谢

最佳答案

这是警告和通知。这不是错误!

通常您可以隐藏它:Joomla 配置 > 服务器选项卡 > 错误报告 - 将其设置为最小值或无。

您还可以在服务器 php.ini 配置文件中修改此设置,或在网站根文件夹中的 php.ini 文件中进行设置(仅在某些服务器上可行)。

但最后您应该修复代码以使用新的 Joomla 框架方法。 例如要获取菜单,请使用:

// Get Joomla! instance
$jAp = JFactory::getApplication();
// Get variables
$menu = $jAp->getMenu();

看看这个 Get vars : https://docs.joomla.org/Retrieving_request_data_using_JInput

关于php - Joomla 3.8 与 PHP 7 问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52994014/

相关文章:

php - Composer 和 Yii

html - 没有滚动条的 Joomla 文章可变高度

joomla - Joomla 管理和前端的单点登录

php - Joomla Extension AcySMS 需要修改源码

php - 如何将 HTML 表单中的值回显到另一个页面上的表格(使用 PHP)

php - 基于单点登录的Web身份验证系统

php - 单击提交按钮时从数据库中选择数据

javascript - 如何以 NO-RESTful 方式使用 Backbone.js?

c# - ASP.Net 网站无法重建解决方案也无法发布

css - 部分网页在主机加载