In PHP there are two basic ways to get output:- echo and print. In this tutorial we use echo statement in almost Examples and we discuss a little bit about print statement. Work of Print and echo statement is almost
Same.

Echo and print statement :-

Echo and print statement is almost same in php. There is a little bit difference between print and echo statement. Difference between echo and print statement is that echo has no return value
And echo statement has the return value of 1 so it can be used in expressions. Echo takes multiple parameters while on the other hand print statement takes
One argument. echo is much faster and easier to use.

PHP echo Statement:-

The echo statement can be used with or without parentheses: echo or echo(). 

Output with echo statement:- 

The following example shows how to output text with the echo command (notice that the text can contain HTML markup).



Output variables with Print statement:- 

The following example shows how to output text and variables with the print statement.

<?php
$text1 = "Learn PHP";
$text2 = "s1school.blogspot.com";
$i = 5;
$s = 4;

print "<h2>$text1</h2>";
print "Study PHP at $text2<br>";
print $x + $y;
?>

IF you have any question about this lecture you can comment blow. feel free to contact me.
you can also Visit my YouTube channel by clicking on this Link YouTube Channel.

0 comments:

Post a Comment

Thanks

 
Blogger Templates1 school © 2013. All Rights Reserved. Powered by Blogger
Top