The PHP echo Statement


SUBMITTED BY: lakben

DATE: Aug. 14, 2017, 9:57 p.m.

FORMAT: PHP

SIZE: 669 Bytes

HITS: 370

  1. The echo statement can be used with or without parentheses: echo or echo().
  2. Display Text
  3. The following example shows how to output text with the echo command (notice that the text can contain HTML markup):
  4. Example:
  5. <?php
  6. echo "<h2>PHP is Fun!</h2>";
  7. echo "Hello world!<br>";
  8. echo "I'm about to learn PHP!<br>";
  9. echo "This ", "string ", "was ", "made ", "with multiple parameters.";
  10. ?>
  11. Display Variables
  12. The following example shows how to output text and variables with the echo statement:
  13. Example:
  14. <?php
  15. $txt1 = "Learn PHP";
  16. $txt2 = "bitbin.it";
  17. $x = 5;
  18. $y = 4;
  19. echo "<h2>$txt1</h2>";
  20. echo "Study PHP at $txt2<br>";
  21. echo $x + $y;
  22. ?>

comments powered by Disqus