PHP Var_export Function Example Explained

Source: Internet
Author: User
The Var_export () function returns the structure information about the variable passed to the function, similar to Var_dump (), unlike the PHP code whose returned representation is legitimate. 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.

This example describes the use of the PHP format output file Var_export function. Share to everyone for your reference. Specific as follows:

Var_export (Array (' A ', ' B ', array (' AA ', ' BB ', ' cc '))//This is no different from Var_dump [code] $var =var_export (Array (' A ', ' B ', Array (' aa ', ' BB ', ' cc '), true)//plus true, will not print out, but give a variable, so you can directly output; echo $var;//The output form is similar to Var_dump () printing.

Example 2, the code is as follows:

The 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:

Array (  ' name ' = = ' abc ',  ' job ' = ' programmer ',  ' a ' = = = Array (  0 = ' AA ',  1 = ' cc ', 
 2 = ' BB ',  ),  

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.