print in php code example
Example 1: How to show php text
<?php
echo "Hello World!";
$YourVariable = "Hello World!";
echo $YourVariable;
?>
Example 2: Difference between echo and print statement in php
Source link:
https:
1. echo Statement
* we can write echo statement with parenthesis like 'echo()' or without parenthesis 'echo'.
* In the echo we can pass multiple variable in comma separated form to see the output like 'echo $a,$b,$c;'
* echo doesn’t return any value
* echo is faster then print
2. Print Statement
* we can write print statement with parenthesis like 'print()' or without parenthesis 'print'.
* In the print we can not pass multiple variable in comma separated form like echo.
* print statement always returns 1.
* print is slower than echo
Example 3: PHP echo and print Statements
<?php
echo "<h2>PHP is Fun!</h2>";
echo "Hello world!<br>";
echo "I'm about to learn PHP!<br>";
echo "This ", "string ", "was ", "made ", "with multiple parameters.";
?>
Example 4: print in php
print_r("");