PHP format output file Var_export function instance, _php tutorial

Source: Internet
Author: User

PHP format output file Var_export function instance,


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:php 4 >= 4.2.0, PHP 5

Var_export--outputs or returns a string representation of a variable.

Description: Mixed var_export (mixed expression [, bool return])

This function returns the structure information about the variable passed to the function, which is similar to Var_dump (), but differs from its return representation as a valid PHP code, and you can return the representation of the variable by setting the second argument of the function to true.

Example: copy code code 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:
Copy the code 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 the Code code as follows: Array (
' Name ' = ' abc ',
' Job ' = ' programmer ',
' A ' + =
Array (
0 = ' AA ',
1 = ' CC ',
2 = ' BB ',
),
)

I hope this article is helpful to everyone's PHP programming.

http://www.bkjia.com/PHPjc/912281.html www.bkjia.com true http://www.bkjia.com/PHPjc/912281.html techarticle PHP Format output file Var_export function instance, the example of this article describes the PHP format output file Var_export function usage. Share to everyone for your reference. Specific as follows: var_export:php ...

  • 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.