PHP print and echo Statements

PHP print and echo Statements

Instructor-svgAl-Mamun Sarkar
Apr 22 , 2020

The following code shows how to print data using print and echo function in PHP Programming.

 

Code:

echo "<p>Welcome to PHP</p>";
echo "Hello, world!<br>";
echo "Welcome ", "to ", "PHP ", "Coding Example  ", "of Artofcse.";

Output:

Welcome to PHP
Hello, world!
Welcome to PHP Coding Example of Artofcse.

 

Print Example:

$var1 = "PHP Coding Example";
$var2 = "artofcse.com";
$a = 5;
$b = 4;

print "<p>" . $var1 . "</p>";
print "Learn PHP at " . $var2 . "<br>";
print $a + $b;

Output: 

PHP Coding Example
Learn PHP at artofcse.com
9

 

Echo Example:

$var1 = "PHP Coding Example";
$var2 = "artofcse.com";
$a = 5;
$b = 4;

echo "<p>" . $var1 . "</p>";
echo "Learn PHP at " . $var2 . "<br>";
echo $a + $b;

Output:

PHP Coding Example
Learn PHP at artofcse.com
9

 

  • Share On:
  • fb
  • twitter
  • pinterest
  • instagram