Embedding PHP in HTML

We can easily embed a PHP script within HTML file, by using PHP tag. It is very useful when you are creating a dynamic application, where you are generating data from Database and what to show those generated data within your page.

For example – You are fetching all users information from MySql Database table and what to display all those users information in HTML table form.

Here, is basic syntax of embedding PHP script in HTML –

<html>
     <body>
          <?php
             // PHP CODE
          ?>
     </body>
</html>

To use PHP script in an HTML file we have to follow following condition –

  • The extension of the file should be .php.
  • This file should be run by using web server which supports PHP script like- Apache

Related Post

Spread the love

Be First to Comment

Leave a Reply

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