1<?php
2 echo "Hello World!";
3// You can also do this with a variable:
4$YourVariable = "Hello World!";
5echo $YourVariable;
6?>
1Source link:
2https://www.programmingquest.com/2019/04/difference-between-echo-and-print.html
3
41. echo Statement
5* we can write echo statement with parenthesis like 'echo()' or without parenthesis 'echo'.
6* In the echo we can pass multiple variable in comma separated form to see the output like 'echo $a,$b,$c;'
7* echo doesn’t return any value
8* echo is faster then print
9
102. Print Statement
11* we can write print statement with parenthesis like 'print()' or without parenthesis 'print'.
12* In the print we can not pass multiple variable in comma separated form like echo.
13* print statement always returns 1.
14* print is slower than echo
1<html>
2<body>
3
4<?php
5$txt1 = "test";
6$txt2 = "test";
7$x = num;
8$y = num;
9
10print "<h2>" . $txt1 . "</h2>";
11print "test " . $txt2 . "<br>";
12print $x + $y;
13?>
14
15</body>
16</html>
17
18