简体   繁体   中英

Calling PHP from Smarty template

I am trying to integrate an ad package into my Smarty based site. I have been given the following PHP code that I need to add to my footer file. But due to it being Smarty I need to add the code instead to my php file so that it can be called/included in my Smarty template file. This was the code that I was given and that I need to include:

    <?php if(function_exists('ad_footer')) ad_footer(); ?>

But in the php file I am not sure how to achieve this - I have got this example and wanted to know if it looked correct??

if(function_exists('ad_footer')) {
 ob_start();
 ad_footer();
 $smarty->assign('ad_footer', ob_get_clean());

}

Does the above look the right way to do it?

Thanks in advance

我继续创建了一个测试页面,看看上面是否有效,但是这样做会坚持使用这段代码。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM