PHP sprintf 转义%
我想要以下输出:-
将从您的充值帐户中扣除 27.59 欧元的 50%。
当我做这样的事情时:-
$variablesArray[0] = '€';
$variablesArray[1] = 27.59;
$stringWithVariables = 'About to deduct 50% of %s %s from your Top-Up account.';
echo vsprintf($stringWithVariables, $variablesArray);
但它给了我这个错误 vsprintf() [function.vsprintf]: Too Fewarguments in ...
因为它考虑了 %
50%
也可用于更换。我该如何逃脱呢?
I want the following output:-
About to deduct 50% of € 27.59 from your Top-Up account.
when I do something like this:-
$variablesArray[0] = '€';
$variablesArray[1] = 27.59;
$stringWithVariables = 'About to deduct 50% of %s %s from your Top-Up account.';
echo vsprintf($stringWithVariables, $variablesArray);
But it gives me this error vsprintf() [function.vsprintf]: Too few arguments in ...
because it considers the %
in 50%
also for replacement. How do I escape it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
用另一个
%
转义它:Escape it with another
%
: