两个变量相减时如何显示加减号: [英] How to show plus and minus sign when subtracting two variables:
本文介绍了两个变量相减时如何显示加减号:的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在两个变量相减时显示正负号:以下代码显示-1,可以,但是当值为正时,则不显示+号.
How to show plus and minus sign when subtracting two variables:Following codes shows -1, that is fine but when the value is positive then it is not showing +sign.
$gf=5;
$ga=6;
$gd=$gf-$ga;
echo $gd;
推荐答案
试试这个:
printf('%+d', $gd);
这篇关于两个变量相减时如何显示加减号:的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文