2012-04-09 82 views
0

我有這樣的錯誤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

回答

3

你可以修改你的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'); 
} 

還要注意}後,你不需要一個分號。