我正在尝试从Joomla 2.5.14获取当前的page_id,user_id和日期。这是我正在使用的代码:
<?php
$foo = $jinput->get('id');
echo $foo;
$user =& JFactory::getUser();
$usr_id = $user->get('id');
echo $usr_id;
$date =& JFactory::getDate();
echo 'Current date and time is: ' . $date->toFormat() . "\n";
?>
JFactory工作正常(我得到当前用户和日期)但是jinput给出错误:
Notice: Undefined variable: jinput in`
答案 0 :(得分:6)
您忘了定义$jinput
:
<?php
$jinput = JFactory::getApplication()->input;
$foo = $jinput->get('id');
echo $foo;
$user = JFactory::getUser();
$usr_id = $user->get('id');
echo $usr_id;
$date = JFactory::getDate();
echo 'Current date and time is: ' . $date->toFormat() . "\n";
?>
另外,您不需要使用&
。
希望这有帮助