Php 显示第三方物流的最佳方法?
我为横幅旋转编码了这个。我想知道如何将它添加到Php 显示第三方物流的最佳方法?,php,smarty,Php,Smarty,我为横幅旋转编码了这个。我想知道如何将它添加到tpl文件中以在那里显示它 <?php $fcontents = join ('', file ('banner_ads.txt')); $s_con = split("~",$fcontents); $banner_no = rand(0,(count($s_con)-1)); echo $s_con[$banner_no]; ?> 首先,您的页面应该包括Smarty模板引擎。在PHP文件中,应该放置逻辑。在这个
tpl
文件中以在那里显示它
<?php
$fcontents = join ('', file ('banner_ads.txt'));
$s_con = split("~",$fcontents);
$banner_no = rand(0,(count($s_con)-1));
echo $s_con[$banner_no];
?>
首先,您的页面应该包括Smarty模板引擎。在PHP文件中,应该放置逻辑。在这个文件中,您获取横幅。然后,可以将其分配给模板 您的代码如下所示:
include('Smarty.class.php');
$smarty = new Smarty;
$fcontents = join ('', file ('banner_ads.txt'));
$s_con = split("~",$fcontents);
$banner_no = rand(0,(count($s_con)-1));
$smarty->assign('banner', $s_con[$banner_no]);
$smarty->display('index.tpl');
{$banner}
现在,在模板中,只需按如下方式放置横幅:
include('Smarty.class.php');
$smarty = new Smarty;
$fcontents = join ('', file ('banner_ads.txt'));
$s_con = split("~",$fcontents);
$banner_no = rand(0,(count($s_con)-1));
$smarty->assign('banner', $s_con[$banner_no]);
$smarty->display('index.tpl');
{$banner}
请告诉我们你所说的第三方物流是什么意思。您使用Smarty吗?是的,我想将其添加到我的tpl文件中