How to use PHP in Html


If we want to use PHP in the Html document, then we have to follow the steps which are given below. Using these simple steps, we can easily add the PHP code.

Step 1: Firstly, we have to type the Html code in any text editor or open the existing Html file in the text editor in which we want to use the PHP.

<!Doctype Html>  
<Html>     
<Head>      
<Title>     
Use a Php in Html  
</Title>  
</Head>  
<Body>   
</Body>   
</Html>  

Step 2: Now, we have to place the cursor in any tag of the <body> tag where we want to add the code of PHP. And, then we have to type the start and end tag of PHP.

 <h1>  
<?php   ?>  
</h1>  

Step 3: After then, we have to type the code of PHP between the tags of PHP.

<h1>  
<?php  
 echo "Hii User!! You are at google Site"   
?>     
</h1>  

Step 4: When we successfully add the PHP code, then we have to save the Html file and then run the file in the browser.

<!Doctype Html>  
<Html>     
<Head>      
<Title>     
Use a Php in Html  
</Title>  
</Head>  
<Body>   
 <h1><?php echo "Hii User!! You are at google Site" ?></h1>  
</Body>   
</Html>  

Leave a Reply

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