How to Print HTML Format and Control Characters in PHP

When we are working with PHP we don’t forget we are interact with the user through a browser. Its Mean that what we will send the text to the browser  it will be interpreted as HTML, it is not like a simple text. So we can make use of HTML to format our text. And we can use control characters than PHP will interpret as a new lines .

Here simple code to add HTML formats to the PHP file .

  1. <html>
  2. <head>
  3. <title> Print HTML Format and Control Characters</title>
  4. </head>
  5. <body>
  6. <h1>Displaying Text From PHP and Use Control Characters</h1>
  7. Here PHP will Print The message like:
  8. <br>
  9. <br>
  10. <?php
  11. echo “<i>welcome <i/>”;
  12. echo “<u>to<u/>”;
  13. echo “<b>webextensionline  Tutorials<b/>”;
  14. ?>
  15. </body>
  16. </html>

Copy or Type this code in your Editor and save it in localhost path in htdocs with the file name as displaytext.php

now start your localhost server and type this file name in localhost browser once server is started.

You will find output like in below image:

Displaying Text From PHP

Displaying Text From PHP

In this output you can see HTML formats like  Italic, underline and Bold HTML formats.

This is the simple way how you  add all HTML formats in PHP to display HTML Format.

Next Tutorial will explain you how to add Control Characters in PHP.

You must be logged in to post a comment Login