私はsprintf()について多くのことを読んだ後ではありませんでしたが、私はそれを知るべきだと決めました。sprintf()が何も出力しないのはなぜですか?
私は先に進み、次のことをしました。
function currentDateTime() {
list($micro, $Unixtime) = explode(" ",microtime());
$sec= $micro + date("s", $Unixtime);
$sec = mb_ereg_replace(sprintf('%d', $sec), "", ($micro + date("s", $Unixtime)));
return date("Y-m-d H:i:s", $Unixtime).$sec;
}
sprintf(currentDateTime());
これは何も印刷しません。一方、printf()関数を使用すると、次のようになります。
printf(currentDateTime());
結果は正常に出力されます。では、これらの2つの関数の違いは何ですか?sprintf()関数を正しく使用するにはどうすればよいですか?
が、私は '() '**サイレント**' printfの' に:) – deed02392
@ deed02392考えて、それを覚えている:あなたは、次のような何かをする必要があると思います's'は文字列を表すのではないのですか? – Pacerier