Echo & Print

<?php

            echo “Hello”;

           $myName=”Your name here”;

           echo $myName;

           print $myName;

?>

In PHP if you want to print the value of a variable or other string then you have to use echo keyword with variable ($myName) or your string (Hello) inside of dual quotation (“Hello“) and last add semicolon (;

Echo Tip

  • You can also use single quotation (‘Hello‘)
  • Direct writing echo before a variable name like  <?php echo $myName; ?>
  • You can also use <?= $myName ?>
  • You can also use <?php print “Some String here “; ?>
  • You can aslo use html tag in side print and echo <?php echo “<h1>Hello !!!</h1>” ?>

Next Concatenation Operators

 

 

 

Leave a Reply

Your email address will not be published. Required fields are marked *