1. Use print_r ($ array/$ var)
Print is the meaning of printing, and R is taken from the word of array. The function is to print the array content. It can print both the array content and common variables.
Print_r ($ _ request );
Print_r ($ _ Get);/* print the content of the form passed using the get Method */
Print_r ($ _ post);/* print the array content passed through the form post Method */
2. Use var_dump ($ object/$ array/$ var)
VaR represents a variable (variable). A variable includes an object, an array, and a scalar variable. Dump has the intention of reversing it. In addition, it outputs all the content of a variable or object.
Var_dump ($ dB);/* print the content of the $ DB database connection object */
Var_dump ($ filehandle);/* print the content of the file handle object */
Var_dump ($ smarty);/* print the smarty template object */
3. Use var_export ($ object/$ array/$ var)
Output or return the character representation of a variable. This function returns the structure information about the variables passed to the function. It is similar to print_r (). The difference is that the returned representation is legal in PHP.Code. You can set the second parameter of the function to true to return the expression of the variable.
For example:Copy codeThe Code is as follows: <? PHP
$ A = array (1, 2, array ("A", "B", "C "));
Var_export ($ );
Echo "<br> ";
$ V = var_export ($ A, true );
Echo $ V;
?>
In the preceding example, $ v = var_export ($ A, true) indicates that PHP returnsSource code, You can directly use the PHP script in the array file.
Instructions:
The preceding three functions can print the object value, system function value, and array content;
△Echo, print, and printf can print variable content, but cannot display arrays and system super variable arrays;
△Print_r and var_dump can print not only arrays and scalar variables, but also object content;
△Var_dump statement can not only print variables and array content, but also display the content of Boolean variables and resources;
△ The var_export function returns the structure information about the variables passed to the function. Similar to the var_dump () function, the difference is that the returned content is legal PHP code.