Diffrence Between Echo and Print??
Posted: Sun Dec 10, 2006 8:21 pm
I don't know how stupid questions can get on here but I have a feeling that I might win some type of award for it.
Anyway.
The question is this. What is the difference between echo and print?
I made a simple code to show my point.
(sorry for code below I am trying to help someone else with php altho I am limited in my knowledge.)
Now someone told me that I should never use print for some reason or another.. altho I cant remember. I always knew echo would print out whatever you had after echo whether it would be something like these below.
or
So what is Print, In the last 3 yrs I have only come across it in one of those Dummy books. So this is farely new to me cause in most code I look at is always echo whatever.
Anyway.
The question is this. What is the difference between echo and print?
I made a simple code to show my point.
(sorry for code below I am trying to help someone else with php altho I am limited in my knowledge.)
Code: Select all
<?php
# This is a Var test code, just showing someone how vars can be the same and diffrent..####
$Kevin = 'Kevin';
$Nkevin = 'Ed';
$nkevin = 'Maybe Kevin';
##### Rest below is the code that is with the Variables vars here.
##### It isn't hard just remove the HTML coding there to see the php code itself.
?>
<!-- Code is above here.. You Cant see it tho.. -->
<!-- PHP can not be seen in HTML format, only the Code it produces. -->
<FONT SIZE="3"><FONT color="Red"><B>Red</B></FONT> is $Kevin<BR>
<FONT color="Blue"><B>Blue</B></FONT> is $Nkevin<BR>
<FONT color="Green"><B>Green</B></FONT> is $nkevin<BR><BR></FONT>
<FONT SIZE="3">We went to meet <font color="red"><B><?php echo $Kevin;?></B></font>, but we found <font color="blue"><B><?php echo $Nkevin;?></B></font>. <font color="green"><B><?php print $nkevin;?></B></font> will be down the street.</FONT>Code: Select all
echo $var;Code: Select all
echo 'stuff here' or "stuff here";