Consider below code :
<?php
function a($txt) {
b("Cleveland");
}
function b($txt) {
var_dump(debug_backtrace());
}
echo '<pre>';
a("Peter");
'</pre>';
?>
Output :
array(2) {
[0]=>
array(4) {
["file"]=>
string(40) "C:\xampp\htdocs\php_playground\hello.php"
["line"]=>
int(6)
["function"]=>
string(1) "b"
["args"]=>
array(1) {
[0]=>
string(9) "Cleveland"
}
}
[1]=>
array(4) {
["file"]=>
string(40) "C:\xampp\htdocs\php_playground\hello.php"
["line"]=>
int(12)
["function"]=>
string(1) "a"
["args"]=>
array(1) {
[0]=>
string(5) "Peter"
}
}
}
Now, consider below code :
<?php
function a($txt) {
b("Cleveland");
}
function b($txt) {
var_dump(debug_backtrace());
}
echo '<pre>'.a("Peter").'</pre>';
?>
Output :
array(2) { [0]=> array(4) { ["file"]=> string(40) "C:\xampp\htdocs\php_playground\hello.php" ["line"]=> int(3) ["function"]=> string(1) "b" ["args"]=> array(1) { [0]=> string(9) "Cleveland" } } [1]=> array(4) { ["file"]=> string(40) "C:\xampp\htdocs\php_playground\hello.php" ["line"]=> int(8) ["function"]=> string(1) "a" ["args"]=> array(1) { [0]=> string(5) "Peter" } } }
Why I'm getting two different outputs for the two different usages of <pre>
tag?
echo '<pre>';
a("Peter");
'</pre>';
AND
echo '<pre>'.a("Peter").'</pre>';
I think I'm doing nothing different in both of the statements. I'm doing almost the same thing then why I'm getting different outputs?