PHP Echo vs Print

PHP Echo vs Print

PHP Echo vs Print

PHP Echo vs Print. As you know Print and Echo are both output data towards output stream.Let see how we can differentiate .

Echo vs Print

Features Print Echo
Return Value Yes No
<?php $myname = True; $myname ?
print "Brian" : 
print "false"; ?>

I set $myname as True Initially , and if $myname
is true print “Brian”

you can’t do that with Echo it does
not have a return value 1 or 0
Multiple Parameter No Yes
You Can’t do that

  print ("Brian"); 

you can only take one parameter at a time

echo  Brian, Pattrick, Richard, Ryan;

 

 echo ("Brian");

You can only echo one if using a parentheses

Concatenation Yes Yes
>

 
<?php $txt1 = "I"; $txt2 = "am"; 
 
$txt3 = "Brian"; print $txt1." " .$txt2 
." " .$txt3 ; ?> 

you can only take one parameter at a time

<?php $txt1 = "I"; $txt2 = "am"; 
$txt3 = "Brian";
 echo "$txt1 ", "$txt2", "$txt3" ; ?>

Or you can choose to remove the
Variable just write : I am Brian “

Processing Speed Slow Fast
Type Speed Print is a Function Echo is a Command

Hopefully now you have a clear idea on PHP Echo vs Print, when ever you have question you can always chck out PHP official website

or Google at stack Overflow, GitHub etc. Feel free to contact me.

Check out on how to install local Server to run PHP

Leave a Reply

Your email address will not be published. Required fields are marked *

7 + 2 =