本文介绍了PHP sprintf转义%的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想要以下输出: -

I want the following output:-

当我做这样的事情: -

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);

但是它给了我这个错误 vsprintf()[function.vsprintf]因为它在 50%中也考虑了 中的参数太少替代。如何逃避它?

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?

推荐答案

使用另一个

$stringWithVariables = 'About to deduct 50%% of %s %s from your Top-Up account.';

这篇关于PHP sprintf转义%的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-16 07:22