How Does PHP works and Embedding PHP in HTML

How Does PHP works and Embedding PHP in HTML

How Does PHP works

Before knowing about the working of PHP you need to understand the difference between HTML and PHP.

The main difference between HTML and PHP is that PHP is used for making the page dynamic and it is the scripting language.

In HTML you write your code then deployed it and the user will download that page along with all the code.

The browser then interprets this code and shows the user the page as you planned for it. HTML code goes to the user same as it is and is interpreted by the browser.

But working with PHP is quite different because you don’t download the code in PHP. You need to know what happens when user request a PHP page? -The code in the requested file is processed by the server then you download the output of the code (in HTML form).

The main aim of working with PHP is to use the processing powers of the server to build the dynamic web pages. This means that if you click "view source" on a PHP page, you are not able to see the PHP codes you will see only HTML tags. Due to this you cannot see how a PHP page is made with the help of "view source".

Embedding PHP in HTML

Normally you embed HTML outside of PHP tags but you can also echo HTML elements within PHP tags.

Have a look on given example :

  1. <?php
  2. Echo "<html>";
  3. Echo "<title>HTML with PHP</title>";
  4. Echo "<b>ExpertPHP Example</b>";
  5. //your php code goes here
  6. ?>

As i told you that you can even embed php code within HTML Tags too, please have a look on given example.

  1. <html>
  2. <head>
  3. <title>Embed PHP within HTML tags</title>
  4. </head>
  5. <body>
  6. Put here your HTML code
  7. <?php
  8.     
  9.         // php code goes here
  10. ?>
  11. Back into normal HTML
  12. </body>
  13. </html>

You can also put your html code within specific conditions of PHP.

  1. <?php if(your condition) { ?>
  2. ... PUT HTML CODE ...
  3. <?php } ?>

Phone: (+91) 8800417876
Noida, 201301
sakarya escort akyazı escort arifiye escort erenler escort eve gelen escort ferizli escort geyve escort hendek escort otele gelen escort sapanca escort söğütlü escort taraklı escort
sakarya escort akyazı escort arifiye escort erenler escort eve gelen escort ferizli escort geyve escort hendek escort karapürçek escort karasu escort kaynarca escort kocaali escort otele gelen escort pamukova escort sapanca escort söğütlü escort taraklı escort
sakarya escort akyazı escort arifiye escort erenler escort eve gelen escort ferizli escort geyve escort hendek escort karapürçek escort karasu escort kaynarca escort kocaali escort otele gelen escort pamukova escort sapanca escort söğütlü escort taraklı escort
sakarya escort akyazı escort arifiye escort erenler escort eve gelen escort ferizli escort geyve escort hendek escort karapürçek escort karasu escort kaynarca escort kocaali escort otele gelen escort pamukova escort sapanca escort söğütlü escort taraklı escort
sakarya escort serdivan escort adapazarı escort sakarya escort bayan sakarya escort sakarya escort sakarya escort sakarya escort sakarya escort sakarya escort sakarya escort sakarya escort sakarya escort sakarya escort sapanca escort sakarya escort