1. Use print_r ($array/$var)
print means printing, and r is taken from the word Array. Then the function of this function is to print the array content. It can print the array content or ordinary variables. .
print_r ($_REQUEST);
print_r ($_GET); /* Print the form content passed using the GET method*/
print_r($_POST); /* Print the array content passed using the form POST method*/
2. Use var_dump ($object/$array/$var)
var represents variable (Variable). Variables include objects, arrays and scalar variables. Dump means dumping. When added together, all the contents of variables or objects are output. .
var_dump($DB); /*Print the contents of the $DB database connection object*/
var_dump($fileHandle); /*Print the contents of the file handle object*/
var_dump($Smarty); /*Print the Smarty template object*/ /
3. Use var_export($object/$array/$var)
to output or return the character representation of a variable. This function returns structural information about the variables passed to the function. It is similar to print_r(), except that the representation returned is legal PHP code. You can return a representation of a variable by setting the second parameter of the function to TRUE.
For example:
Copy code The code is as follows:
$a = array ( 1,2, array("a","b","c")) ;
var_export ( $a) ;
echo "
" ;
$v = var_export ( $a , TRUE) ;
echo $v ;
?>
The above introduces the implementation code for displaying arrays and objects in PHP to realize common prosperity, including the content of realizing common prosperity. I hope it will be helpful to friends who are interested in PHP tutorials.