printfとsprintfの違い



Difference Between Printf



  1. Printf関数:
int printf ( string format [, mixed args [, mixed ...]] ) Produces output according to format , which is described in the documentation for sprintf() . Returns the length of the outputted string.

テキストをフォーマットして、次のように出力します。

$name='hunte' $age=25 printf('my name is %s, age %d', $name, $age)
  1. Sprintf関数:
string sprintf ( string format [, mixed args [, mixed ...]] ) Returns a string produced according to the formatting string format .

printfに似ていますが、印刷されません 代わりに、フォーマットされたテキストを返します。残りはprintfと同じです。



  1. 印刷機能:

関数であり、値を返すことができ、パラメータを1つだけ持つことができます。

int print ( string arg ) Outputs arg . Returns 1 , always.