1. Use Print_r ($array/$var)
Print is the meaning of printing, and R is taken from the array of words, then the function is to play a set of content, it can either print the contents of the array, you can print the ordinary variables.
Print_r ($_request);
Print_r ($_get); /* Print form content that is passed using the Get method.
Print_r ($_post); /* Print the contents of the array passed with the form POST method * *
2. Use Var_dump ($object/$array/$var)
var represents a variable (Variable), a variable that includes an object, an array, and a scalar variable, and the dump has an inverted meaning, added to it, that is, the contents of the variable or object are all exported.
Var_dump ($DB); /* Print the contents of the $DB database connection object * *
Var_dump ($fileHandle); /* The contents of the print file handle Object * *
Var_dump ($Smarty); /* Print Smarty Template Object * *
3. Use Var_export ($object/$array/$var)
The character representation of the output or return of a variable. This function returns the structure information about the variable passed to the function, which is similar to Print_r (), and differs from its return representation as a valid PHP code. You can return the representation of a variable by setting the second argument of the function to true.
For example:
Copy Code code as follows:
<?php
$a = Array (1,2, array ("A", "B", "C"));
Var_export ($a);
echo "<br>";
$v = Var_export ($a, TRUE);
Echo $v;
?>
In the example above, $v = Var_export ($a, TRUE) indicates that the source code of PHP is returned, which can be used directly in the PHP script's array file.
Related instructions:
All three of these functions can print the value of the object, the value of the system function, and the contents of the array;
echo, print, and printf can print variable content, but cannot display array and system super variable array;
Print_r and Var_dump can not only print arrays, scalar variables, but also print the contents of objects;
Var_dump statements can not only print variables, array contents, but also display the contents of Boolean variables and resources (RESOURCE);
The Var_export function returns the structural information about the variable passed to the function, similar to the Var_dump () function, and the difference is that the returned content is valid PHP code.