A var_dump
(PHP 3 >= 3.0.5, PHP 4, PHP 5)
Var_dump--Information about printing variables
Describe
void Var_dump (mixed expression [, mixed expression [, ...]])
This function displays structure information about one or more expressions, including the type and value of the expression. The array recursively expands the value and displays its structure by indentation.
Copy CodeThe code is as follows:
$data = Array (' name ' = ' abc ', ' job ' = ' programmer ', ' a ' =>array (' AA ', ' cc ', ' BB '));
$data = Var_dump ($data, TRUE);
Echo $data;
The output form is as follows:
Copy CodeThe code is as follows:
Array (3) {
["Name"]=>
String (3) "ABC"
["Job"]=>
String (Ten) "Programmer"
["A"]=>
Array (3) {
[0]=>
String (2) "AA"
[1]=>
String (2) "CC"
[2]=>
String (2) "BB"
}
}
BOOL (TRUE)
two Var_export
(PHP 4 >= 4.2.0, PHP 5)
Var_export--Output or return a string representation of a variable
Describe
Mixed var_export (mixed expression [, bool return])
This function returns the structure information about the variable passed to the function, similar to Var_dump (), unlike the PHP code whose returned representation is valid.
You can return the representation of a variable by setting the second argument of the function to TRUE.
EG:
Var_export (Array (' A ', ' B ', array (' AA ', ' BB ', ' cc '))) This is no different from var_dump;
$var =var_export (Array (' A ', ' B ', array (' AA ', ' BB ', ' cc '), true), plus true, will not print again, but give a variable, so that it can be directly output;
echo $var; the output comes in a similar form to Var_dump ().
EG2
Copy CodeThe code is as follows:
$data = Array (' name ' = ' abc ', ' job ' = ' programmer ', ' a ' =>array (' AA ', ' cc ', ' BB '));
$data = Var_export ($data, TRUE);
Echo $data;
The output form is as follows:
Copy CodeThe code is as follows:
Array (
' Name ' = ' abc ',
' Job ' = ' programmer ',
' A ' + =
Array (
0 = ' AA ',
1 = ' CC ',
2 = ' BB ',
),
)
The following are additional information:
Error_log (Var_export (Yblog_mspconfiginit ("ratings"), true);
Cause of the problem
Var_export must return a valid PHP code, that is, the code returned by Var_export can be directly assigned to a variable as PHP code. And this variable gets the same value as the Var_export type. However, when the variable type is resource, it cannot be copied in simple copy, so var_export returns NULL when the variable of Var_export is the resource type.
Problem finding
While tracking the Yratings_get_targets,
Copy CodeThe code is as follows:
Error_log (Var_export (Yblog_mspconfiginit ("ratings"), true); always print out the return of Yblog_mspconfiginit ("ratings") is null
Cause I thought it was impossible to establish and DB connection, went the wrong way a day.
Finally found that this is one of the differences between Var_export and Var_dump.
This is:
Cause of the problem
Var_export must return a valid PHP code, that is, the code returned by Var_export can be directly assigned to a variable as PHP code. And this variable gets the same type of value as the Var_export.
However, when the variable type is resource, it cannot be copied in simple copy, so var_export returns NULL when the Var_export variable is resource type.
Instance
Copy CodeThe code is as follows:
$res = Yblog_mspconfiginit ("ratings");
Var_dump ($res);
Var_export ($res);
Results:
Copy CodeThe code is as follows:
Resource (1) of type (Yahoo_yblog)
Null again for example:
Copy CodeThe code is as follows:
$res = fopen (' status.html ', ' R ');
Var_dump ($res);
Var_export ($res);
Results:
Copy CodeThe code is as follows:
Resource (2) of type (stream)
Null
http://www.bkjia.com/PHPjc/322468.html www.bkjia.com true http://www.bkjia.com/PHPjc/322468.html techarticle a var_dump (php 3 = 3.0.5, PHP 4, PHP 5) var_dump--Information about the print variable describes the void Var_dump (mixed expression [, mixed expression [, ...]] This function displays information about one or ...