Different _php techniques for PHP var_export and var_dump output

Source: Internet
Author: User

Problem found
While tracking the Yratings_get_targets,
Error_log (Var_export (Yblog_mspconfiginit ("ratings"), true); always print out yblog_mspconfiginit ("ratings") return is null

Cause I thought it was impossible to build a connection with DB and took the wrong way for the day.
Finally found that this is one of the differences between Var_export and Var_dump.

This is:
Problem reason
Var_export must return valid PHP code, that is to say, the code returned by Var_export can be assigned a variable directly as a PHP code. And this variable will get the same type of value as being var_export.

However, when the variable type is resource, it cannot be copied by simple copy, so when the Var_export variable is a resource type, VAR_EXPORT returns null

Instance
$res = Yblog_mspconfiginit ("ratings");
Var_dump ($res);
Var_export ($res); Results:

Resource (1) of type (Yahoo_yblog)
Null again for example:

$res = fopen (' status.html ', ' R ');
Var_dump ($res);
Var_export ($res); Results:

Resource (2) of type (stream)
Null

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.