PHP智者变量错误

问题描述:

我有这样的错误PHP智者变量错误

“注意:未定义的变量:LOGO在C:\ WAMP \ WWW \ SITE \ TOOLS \ SMARTY \ SYSPLUGINS \ SMARTY_INTERNAL_DATA.PHP ON LINE 291 CALL STACK”

这是我的PHP代码

function hookFooter($params) 
{ 
    global $smarty; 
    $smarty->assign('ENT_QUOTES', ENT_QUOTES); 
    if(file_exists('modules/ebbrandingfooter/logo-footer.jpg')){ 
     $smarty->assign('logo','modules/ebbrandingfooter/logo-footer.jpg'); 
    }; 
    $FOOTERdescription=Configuration::get('FOOTER_DESC'); 
    $smarty->assign('description',$FOOTERdescription); 
    return $this->display(__FILE__, 'ebbrandingfooter.tpl'); 
} 

这里的TPL

{if $logo}<img src="{$logo}" />{/if} 
    <p>{$description}</p> 

任何人都可以帮助我,我做错了什么? THX !!!

+2

是你的if(file_exists)条件返回true吗?如果没有,您的标志var assignement不会发生,然后您的TPL将调用一个不存在的标志变量。你已经试图在TPL中解决它,说“如果$ logo”,但它仍然在检查布尔值...你应该说,如果isset $ logo改为 – Kristian 2012-04-09 15:05:40

你可以修改你的PHP代码,以确保$标志设置,e.g:

function hookFooter($params) 
{ 
    global $smarty; 
    $smarty->assign('ENT_QUOTES', ENT_QUOTES); 
    if(file_exists('modules/ebbrandingfooter/logo-footer.jpg')){ 
     $smarty->assign('logo','modules/ebbrandingfooter/logo-footer.jpg'); 
    } else { 
     $smarty->assign('logo', null); 
    } 
    $FOOTERdescription=Configuration::get('FOOTER_DESC'); 
    $smarty->assign('description',$FOOTERdescription); 
    return $this->display(__FILE__, 'ebbrandingfooter.tpl'); 
} 

还要注意}后,你不需要一个分号。