PHPのprintfとsprintfの違い
<?php $num = 5; $location = 'tree'; $format = 'There are %d monkeys in the %s'; printf($format, $num, $location); // 出力する echo sprintf($format, $num, $location); // 文字列を返す(sprintfだけでは出力しない)
<?php $num = 5; $location = 'tree'; $format = 'There are %d monkeys in the %s'; printf($format, $num, $location); // 出力する echo sprintf($format, $num, $location); // 文字列を返す(sprintfだけでは出力しない)