In
PHP Print function 1 echo ()
You can output multiple strings at the same time, multiple parameters, no parentheses, no return values.
PHP Printing function 2 print ()
You can only output one string at a time, one parameter, a parenthesis, a return value, and flase when its execution fails. Print is used in a similar way to the C language, so there is a special explanation for the% in the output content.
PHP Print function 3 die ();
There are two functions: output the content first, then exit the program. (commonly used in linked servers, databases)
Mysql_connect ("Locahost", "root", "root") or Die ("link server failed!") ");
PHP Print function 4 printf ();
printf ("Parameter 1", Parameter 2): Parameter 1 = output by what format; parameter 2= the output variable. ($s: by string, $d: by Integer, $b: by Binary, $x: by 16, $o: by octal; $f: by floating-point type)
- < ? PHP
- $ Num = - . 001;
- printf ("%d", $num); 100
- printf ("%s", $num); 100.001
- printf ("%s---%d---%b---%x---%o---%f", $num, $num, $num, $num, $num, $num)
- 100.001------1100100------144---1001.00100
- printf ("%.2f", $num); 100.00 (decimal point reserved 2 digits)
- printf ("%.1f", $num); 100.0 (decimal point reserved 1 digits)
- printf ("% ' #10s", $num); # # #100.001
- printf ("% ' @10s", $num); @@@100.001
- printf ("% ' _10s", $num); ___100.001
- printf ("% ' #-10s", $num); 100.001###
- printf ("% ' @-10s", $num); 100.001@@@
- printf ("% ' _-10s", $num); 100.001___
- printf ("% ' #20s", $num); ############ #100.001
- ?>
PHP Print function 5 sprintf ();
This cannot be output directly, first assigning a variable, and then outputting the variable.
- < ? PHP
- $ Num = - . 001;
- $ a = sprintf ("%d", $num);
- echo $a; 100
- ?>
PHP Print function 6 print_r ();
Function: Used only for output arrays.
PHP Print function 7 var_dump ();
Function: Output variable content, type, or string content, type, length. Commonly used to debug.
- < ? PHP
- $ a = - ;
- Var_dump ($a); Int (3) 100
- ?>
http://www.bkjia.com/PHPjc/446291.html www.bkjia.com true http://www.bkjia.com/PHPjc/446291.html techarticle in PHP print function 1 echo () can output multiple strings at the same time, can be multiple parameters, do not need parentheses, no return value. PHP Printing function 2 print () can only output one string at a time ...