Differences between the three functions var_dump, var_export, and print_r in php

Source: Internet
Author: User
This article describes the differences between var_dump, var_export, and print_r functions in php. For more information, see

This article describes the differences between var_dump, var_export, and print_r functions in php. For more information, see

The following example shows the specific differences between the three functions. var_dump and var_export are less useful, and Hong Kong servers are rented, but they are similar. So you can see:

The Code is as follows:


$ A = array (32,322,343, 32,232,232 3, array (32 ));
$ B = 1234;
$ C = "alsdfl; asdf ";
$ D = 'a ';
$ E = fopen ("slsl.txt", "r ");
Var_dump ($ );
Echo"
";
Var_dump ($ B );
Echo"
";
Var_dump ($ c );
Echo"
";
Var_dump ($ d );
Echo"
";
Var_dump ($ e );
Echo"
";
Echo"
";
Echo"
";
Echo"
";
Var_export ($ );
Echo"
";
Var_export ($ B );
Echo"
";
Var_export ($ c );
Echo"
";
Var_export ($ d );
Echo"
";
Var_export ($ e );
Echo"
";
Echo"
";
Echo"
";
Echo"
";
Print_r ($ );
Echo"
";
Print_r ($ B );
Echo"
";
Print_r ($ c );
Echo"
";
Print_r ($ d );
Echo"
";
Print_r ($ e );
Echo"
";


Output:

The Code is as follows:


Warning: fopen(slsl.txt) [function. fopen]: failed to open stream: No such file or directory in E: \ mywww \ yangtest \ base1.php on line 6
Array (6) {[0] => int (1) [1] => int (1) [2] => int (32) [3] => int (322) [4] => int (3433) [5] => array (3) {[0] => int (32) [1] => int (232) [2] => int (23232 )}}
Int (1234)
String (11) "alsdfl; asdf"
String (1) ""
Bool (false)
Array (0 = & gt; 1, 1 = & gt; 1, 2 = & gt; 32, 3 = & gt; 322, 4 = & gt; 3433, 5 = & gt; array (0 = & gt; 32, 1 => 232, 2 => 23232 ,),)
1234
'Alsdfl; asdf'
'A'
False
Array ([0] => 1 [1] => 1 [2] => 32 [3] => 322 [4] => 3433 [5] => Array ([ 0] => 32 [1] => 232 [2] => 23232 ))
1234
Alsdfl; asdf
A


Now we can see the effect. Note that the last one is not pasted, but is not displayed.

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.