Rate Us :
Share with Friends :
Output Functions in PHP :
This function displays output on browser & returns a boolean value 'true', if output is printed successfully, otherwise 'false'. We cannot print multiple statement with single print statement.
In PHP, the value of true is '1' and false means 'no value'.
Example :<?php $a = "ABC"; print $a; ?>
It is same as print function. But we can print multiple statements with single echo function. This function doesn't return any value, that's why it is faster than print function.
Example :<?php echo "ABC","DEF"; ?>
This function displays variable value along with it's data type.
Example :<?php $n = 111; var_dump($n); ?>
By using this function, we can display output with the help of formal specifier.
Example :<?php $a = 10; $user = "Man"; printf("%s has %d cars",$user,$a); ?>
Output :Man has 10 cars
By using this function, we can display all elements of an Array & property of an Object.
Example :<?php $arr = array(10,20,30,40); print_r($arr); ?>
Output :Array (  => 10  => 20  => 30  => 40 )