Home >Backend Development >PHP Tutorial >The difference between php var_export and var_dump output_PHP tutorial

The difference between php var_export and var_dump output_PHP tutorial

WBOY
WBOYOriginal
2016-07-21 14:59:50865browse

Problem Found
When tracking yratings_get_targets,
error_log(var_export(yblog_mspconfiginit("ratings"),true)); always prints out yblog_mspconfiginit( "ratings") returns 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:
Cause of the problem
var_export must return legal php code, that is to say, the code returned by var_export can be directly assigned as php code a variable. And this variable will get the same type of value as var_export

However, when the variable type is resource, it cannot be copied simply. Therefore, when the variable of var_export is of resource type, var_export will return NULL

Example
$res = yblog_mspconfiginit("ratings");
var_dump($res);
var_export($res); Result:

resource(1) of type (yahoo_yblog)
NULL Another example:

$res = fopen('status.html', 'r');
var_dump($res);
var_export($res); Result:

resource(2) of type (stream)
NULL

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/328116.htmlTechArticleThe problem was found when tracking yratings_get_targets, error_log(var_export(yblog_mspconfiginit("ratings"),true)); old It prints out the return value of yblog_mspconfiginit("ratings") which is NULL...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn