Joomla Parse error: syntax error, unexpected T

This question already has an answer here:

  • PHP expects T_PAAMAYIM_NEKUDOTAYIM? 7 answers

  • The scope resolution operator (::) can only be used on a class referenced using a variable from PHP 5.3 -- you're using 5.2.

    You'd have to do JHtmlSidebar::addEntry or JSubMenuHelper::addEntry ; you can't do $class::addEntry .


    JText::('COM_TZ_PORTFOLIO_SUBMENU_GROUP_FIELDS') is not calling a method. It should be:

    JText::_('COM_TZ_PORTFOLIO_SUBMENU_GROUP_FIELDS')
    

    See JText .


    T_PAAMAYIM_NEKUDOTAYIM refers to the two colons in a row like this :: . Looking at your code sample:

    $class::addEntry( JText::('COM_TZ_PORTFOLIO_SUBMENU_GROUP_FIELDS'), 'index.php?option=com_tz_portfolio&view=fieldsgroup', $vName == 'fieldsgroup');
    

    I believe the issue is with JText::( . As per Joomla documentation that should be formatted with an underscore so it is JText::_( so your code would be:

    $class::addEntry( JText::_('COM_TZ_PORTFOLIO_SUBMENU_GROUP_FIELDS'), 'index.php?option=com_tz_portfolio&view=fieldsgroup', $vName == 'fieldsgroup');
    

    Not 100% clear on Joomla internals, but that underscore ( _ ) is actually a function/method of some sort within the JText class. So when you were calling it as JText::( PHP choked because it had no idea what you were trying to do with JText . By adding that underscore ( _ ), it will now actually call a function within a class & do what it has to do.

    链接地址: http://www.djcxy.com/p/69434.html

    上一篇: 更好的迭代显示对象属性PHP

    下一篇: Joomla Parse错误:语法错误,意外的T