开发者

unexpected T_VARIABLE error caused by Joomla getUser method

开发者 https://www.devze.com 2023-01-14 15:22 出处:网络
I\'m getting the following error in a Joomla model file: unexpected T_VARIABLE, expecting T_FUNCTION in /var/www/html/clientFiles/components/com_arrcard/models/buynow.php on line 13

I'm getting the following error in a Joomla model file:

unexpected T_VARIABLE, expecting T_FUNCTION in /var/www/html/clientFiles/components/com_arrcard/models/buynow.php on line 13

Here's the beginning of the file, up through line 14:

<?php

defi开发者_开发技巧ned( '_JEXEC' ) or die( 'Restricted access' );

 jimport('joomla.application.component.model');

class ArrcardModelBuynow extends JModel
{
    public $failedFields = array();
    public $certificateNumber, $emailAddr, $voucherID, $voucherNbr, $userAcctID;

    //check if user is logged in
        $user =& JFactory::getUser();
        $userAcctID = $user->id;

Does anyone know why the getUser line is causing problems? I've used that code in a number of other places with no errors.


As the error says, this code:

//check if user is logged in
$user =& JFactory::getUser();
$userAcctID = $user->id;

must be inside a function. Directly in the class, you can only declare member variables. $user doesn't even seem to be defined somewhere.

0

精彩评论

暂无评论...
验证码 换一张
取 消