PHP Echo – Shishir Kant Singh https://shishirkant.com Jada Sir जाड़ा सर :) Tue, 26 May 2020 05:50:13 +0000 en-US hourly 1 https://wordpress.org/?v=6.9 https://shishirkant.com/wp-content/uploads/2020/05/cropped-shishir-32x32.jpg PHP Echo – Shishir Kant Singh https://shishirkant.com 32 32 187312365 PHP echo and print statement https://shishirkant.com/php-echo-and-print-statement/?utm_source=rss&utm_medium=rss&utm_campaign=php-echo-and-print-statement Tue, 26 May 2020 05:50:10 +0000 http://shishirkant.com/?p=805 If there is an input then it must have an output. So in PHP also there is two statements which are used for displaying output data to the screen

  • echo
  • print

Both the statement are used for displaying data on the screen.

Difference between ‘echo’ and ‘print’

echoprint
This statement can pass multiple string separated by ‘,’.It cannot pass multiple strings.
It doesnot return any values.It always return 1.
It is faster than print.It is slower than echo.
Examples of ‘echo’ statement
Example for single string input
<html>
<body>
<?PHP
	echo "<h1>shishirkant.com</h1>";
	echo "welcome to PHP world <br>";
?>
</body>
</html>

Output:
shishirkant.com
welcome to PHP world

Example for multiple string input
<html>
<body>
<?PHP
	echo "PHP", "is", "one ", "of", "the","easiest","internet","technology.";
?>
</body>
 </html>

Output:
PHPisone oftheeasiestinternettechnology.

Input through variable
<html>
 <body>
<?PHP
	$a = "welcome to";
	$b = "shishirkant.com";
	echo "<h1>$a</h1>";
	echo " $b<br>";
?>
</body>
</html>

Output:
welcome to
shishirkant.com

Examples of ‘print’ statement

Example
 <html>
 <body>
 <?PHP
	print "<h1>shishirkant.com</h1>";
	print "welcome to PHP world <br>";
?>
</body>
 </html>
 

Output:
shishirkant.com
welcome to PHP world

Input through variable
<html>
 <body>
<?PHP
	$a = "welcome to";
	$b = "shishirkant.com";
	print "<h1>$a</h1>";
	print " $b<br>";
?>
</body>
 </html>

Output:
welcome to
shishirkant.com

]]>
805