answersLogoWhite

0


Best Answer

Print always returns a value of true, but echo doesn't.

echo also has a short cut syntax meaning you can immediately follow the php tags by an equals sign and it will echo the result like in the example shown below:

<?=$hello?>

User Avatar

Wiki User

13y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: What is the difference between echo and print in PHP?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Basic Math

What is the difference between echo and print and printf in PHP?

The print function is slightly more dynamic than the echo function by returning a value, and the echo function is slightly (very slightly) faster. The printf function inserts dynamic variables/whatever into wherever you want with special delimiters, such as %s, or %d. For example, printf('There is a difference between %s and %s', 'good', 'evil') would return 'There is a difference between good and evil'.


How to display a variable in PHP using echo or print statements?

displaying a variable in php using echo statement? &lt;?php $name="ram"; //declaring and defining the variable echo "$name"; //printing the variable using echo command ?&gt;


What PHP statement outputs text on the screen?

There are several different ways to output text on the screen in PHP two of the most common are echo and print. echo "Hello World!"; print ("Hello World!"); Would both print ... Hello World!


1 121 12421 1248421 print these in php programming?

Assuming you just want those integers printed you can do so like this: &lt;?php echo 1; echo 121; echo 12421; echo 1248421; ?&gt; However, if you're looking for how to print these in some sort of power of 2 in terms of a homework assignment, you can pretty easily find some hints by simple searching the significance of those numbers.


How do you write a program to print even numbers from 1 to 50 in PHP?

Code Below: &lt;?php $j = 100; // Set limit upper limit echo "Even Numbers are: &lt;br/&gt;"; for($i=1;$i&lt;=$j;$i++) { if($i%2) { continue; } else { echo $i."&lt;br/&gt;"; } } ?&gt;

Related questions

What is a regular expression in PHP?

echo or print &lt; both of which write text: &lt;?php echo "TEXT"; print "TEXT"; ?&gt;


What is the difference in accuracy between single and double beam echo sounder?

&gt; You can use PHP variable name inside the double quote ("") Eg:- $name = 'Udit'; echo "Hello $name"; It will print: Hello Udit


What is the difference between echo and print and printf in PHP?

The print function is slightly more dynamic than the echo function by returning a value, and the echo function is slightly (very slightly) faster. The printf function inserts dynamic variables/whatever into wherever you want with special delimiters, such as %s, or %d. For example, printf('There is a difference between %s and %s', 'good', 'evil') would return 'There is a difference between good and evil'.


How to display a variable in PHP using echo or print statements?

displaying a variable in php using echo statement? &lt;?php $name="ram"; //declaring and defining the variable echo "$name"; //printing the variable using echo command ?&gt;


What PHP statement outputs text on the screen?

There are several different ways to output text on the screen in PHP two of the most common are echo and print. echo "Hello World!"; print ("Hello World!"); Would both print ... Hello World!


What is difference between language constracter and function for exampal echo print in php language?

I think you mean language construct... Anyway, a function usually takes one or more arguments as comma separated values or variables. echo and print don't &lt;?php $email = 'user@example.com'; $domain = strstr($email, '@'); echo $domain; // prints @example.com ?&gt; Here the strstr function takes a variable string and a constant string as an argument. echo simply displays the contents of the resulting variable. There are a couple functions that don't require arguments, like die() &amp; exit()


1 121 12421 1248421 print these in php programming?

Assuming you just want those integers printed you can do so like this: &lt;?php echo 1; echo 121; echo 12421; echo 1248421; ?&gt; However, if you're looking for how to print these in some sort of power of 2 in terms of a homework assignment, you can pretty easily find some hints by simple searching the significance of those numbers.


How do you get data back and forth between HTML and PHP?

Via AJAX. Another simpler way would be to use form elements and submit them via html and let PHP process the data. Processed data can be output in html form via echo or print statements in php.


How do you go from HTML form to php?

Build your form in HTML and specify your PHP file in the action of the document. HTML does the form stuff, PHP the processing (although you can - of course - use HTML inside PHP via print() or echo(), too)


How do you write a program to print even numbers from 1 to 50 in PHP?

Code Below: &lt;?php $j = 100; // Set limit upper limit echo "Even Numbers are: &lt;br/&gt;"; for($i=1;$i&lt;=$j;$i++) { if($i%2) { continue; } else { echo $i."&lt;br/&gt;"; } } ?&gt;


How can you print 5 54 543 5432 54321?

in PHP: for($n = 5; $n &gt;= 1; $n--){ for($m = 5; $m &gt;= $n; $m--){ echo $m; } echo " "; }


How do you put HTML in PHP?

Its done exactly the same as when you put it in an HTML file. There are 2 ways you can do it: &lt;html&gt; &lt;?php // php stuff ?&gt; &lt;/html&gt; Or you can do it like this: &lt;?php echo "&lt;html&gt;"; // php stuff echo "&lt;/html&gt;"; ?&gt;