PHP sprintf escaping %

后端 未结 3 983
無奈伤痛
無奈伤痛 2020-11-30 20:06

I want the following output:-

About to deduct 50% of € 27.59 from your Top-Up account.

when I do something like this:-



        
3条回答
  •  失恋的感觉
    2020-11-30 20:53

    It is very easy.

    Put another % in front of the original % to escape it.

    For example,

    $num=23;
    printf("%%d of 23 = %d",$num);
    

    Output:

    %d of 23 = 23
    

提交回复
热议问题