Home  >  Article  >  Backend Development  >  Analyze the differences between the three functions var_dump, var_export and print_r in PHP_PHP Tutorial

Analyze the differences between the three functions var_dump, var_export and print_r in PHP_PHP Tutorial

WBOY
WBOYOriginal
2016-07-21 15:04:391065browse

The following example looks at the specific differences between these three functions. Var_dump and var_export are less commonly used, but they are very similar. So you can take a look:

Copy code The code is as follows:

$a = array(1 ,1,32,322,3433,array(32,232,23232));
$b = 1234;
$c = "alsdfl;asdf";
$d = 'a';
$e = fopen("slsl.txt", "r");
var_dump($a);
echo "
";
var_dump($b);
echo "< br>";
var_dump($c);
echo "
";
var_dump($d);
echo "
";
var_dump($ e);
echo "
";
echo "
";
echo "
";
echo "
";
var_export($a);
echo "
";
var_export($b);
echo "
";
var_export($c);
echo "
";
var_export($d);
echo "
";
var_export($e);
echo "
";
echo "
";
echo "
";
echo "
";
print_r($a);
echo "
";
print_r($b);
echo "
";
print_r($c);
echo "
";
print_r($d);
echo "
";
print_r($e);
echo "
";

Output:
Copy code The code is as follows:

Warning: fopen(slsl.txt) [function.fopen]: failed to open stream: No such file or directory in E:mywwwyangtestbase1.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) "a"
bool(false)
array ( 0 => 1, 1 => 1, 2 => 32, 3 => 322, 4 => 3433, 5 => array ( 0 => 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 ) Show something.



http://www.bkjia.com/PHPjc/327763.html

www.bkjia.com

true

TechArticleThe following example looks at the specific differences of these three functions. Among them, var_dump and var_export are less used, but they The two are very similar. So you can take a look: Copy the code The code is as follows: ?ph...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn