print vs echo
Bonus Point - print_r
echo and print are more or less the same. They are both used to output data to the screen. The differences are small: echo has no return value while print has a return value of 1 so it can be used in expressions. echo can take multiple parameters (although such usage is rare) while print can take one argument. echo is marginally faster than print.
About print_r :-
Definition and Usage The print_r() function prints the information about a variable in a more human-readable way.<?php $ret = print("hello world");
print "Return by print function = ".$ret;
//$ret_echo = echo "hello "; not possible
echo "No return in echo";
$var = print_r("hello",true); echo $var;
$a = array("red", "green", "blue"); print_r($a); ?>
Result above code -
hello worldReturn by print function = 1
No return in echo
hello
Array ( [0] => red [1] => green [2] => blue )
1 Comments
Post kaisa laga comment kar ke bataye aur kisi topic pe post chahate hai to comment kare, O topic hum jarur cover karenge .
ReplyDelete