Differences between the three functions var_dump, var_export, and print_r in php
Source: Internet
Author: User
This article gives a detailed analysis of the differences among the three functions var_dump, var_export, and print_r in php, for more information about these functions, see the following examples. var_dump and var_export are less useful, 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 you can see the effect. Note that the last one is not pasted, but is not displayed.
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