2018年11月27日 星期二

sprintf

<?php
$number = 2;
$name = "Jack";
$txt = sprintf( " %s has %d cars.", $name,$number );
echo $txt;
?>

python3 Sprintf
number = 2
name = 'Jack'
print( "{0} has {1} cars".format(name, number) )

输出:
Jack has 2 cars