Home > Article > Backend Development > The difference between var_export and var_dump
When tracking yratings_get_targets,
error_log(var_export(yblog_mspconfiginit("ratings"),true));<br/>
always prints out that the return value of yblog_mspconfiginit("ratings") is NULL
As a result, I thought that the connection to the DB could not be established, and I went on the wrong path for a day.
Finally, I discovered that this is one of the differences between var_export and var_dump
This is:
var_export must Returns legal PHP code. In other words, the code returned by var_export can be directly assigned to a variable as PHP code. And this variable will get the same type of value as var_export
However, when the variable type is resource, it cannot be simply copied. Therefore, when the variable of var_export is of resource type, var_export will Return NULL
$res = yblog_mspconfiginit("ratings");<br/>var_dump($res);<br/>var_export($res);<br/>
resource(1) of type (yahoo_yblog)<br/>NULL<br/>
$res = fopen('status.html', 'r');<br/>var_dump($res);<br/>var_export($res);<br/>
resource(2) of type (stream)<br/>NULL<br/>
For more PHP related knowledge, please visit PHP Chinese website!
The above is the detailed content of The difference between var_export and var_dump. For more information, please follow other related articles on the PHP Chinese website!