{$smarty.post.email}
输出“[电子邮件受保护]”
{$smarty.post.email|count}
输出“1”而不是“14”——字符串长度。
{$smarty.post.email[0]|count}
也输出“1”。
如何找到名为“email”的密钥的长度?
使用
{$smarty.post.email|count_characters:true}
来源:http://www.smarty.net/docsv2/en/language.modifier.count.characters.tpl
$count = strlen($smarty.post.email);
$count = strlen($smarty[post][email]);
strlen 返回字符串的长度。键名称是字符串。
count 返回数组中键的数量。
使用
count_characters
代替 count
:
{$smarty.post.email|count_characters}
输出“14”