Smarty中是否有方法获取字符串的文件扩展名
因为我们可以使用explode函数或in_数组检查在php中获取文件扩展名。 Smarty中是否有方法获取字符串的文件扩展名。 但是我们如何使用smarty在tpl页面中获得文件扩展名呢?目前我正在将所有扩展名作为数组传递,并使用{foreach}在tpl文件中列出 试试这个Smarty中是否有方法获取字符串的文件扩展名,smarty,Smarty,因为我们可以使用explode函数或in_数组检查在php中获取文件扩展名。 Smarty中是否有方法获取字符串的文件扩展名。 但是我们如何使用smarty在tpl页面中获得文件扩展名呢?目前我正在将所有扩展名作为数组传递,并使用{foreach}在tpl文件中列出 试试这个 <?php $smarty->assign('filename', 'foo\bar.txt'); ?> {*你得到了'txt'*}试试这个 <?php $smarty-&g
<?php
$smarty->assign('filename', 'foo\bar.txt');
?>
{*你得到了'txt'*}试试这个
<?php
$smarty->assign('filename', 'foo\bar.txt');
?>
{*you get'txt'*}我使用了一个我创建的插件:
<?php
function smarty_modifier_file_extension($file)
{
$bits = explode('.',$file);
$ext = $bits?array_pop($bits):'';
return $ext;
}
我使用了一个专门为此创建的插件:
<?php
function smarty_modifier_file_extension($file)
{
$bits = explode('.',$file);
$ext = $bits?array_pop($bits):'';
return $ext;
}