Broadly speaking, when it comes to using PHP in HTML, there are two different approaches. The first is to embed the PHP code in your HTML file itself with the .html extension—this requires a special consideration, which we’ll discuss in a moment. The other option, the preferred way, is to combine PHP and HTML tags in .php files.
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 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>
![PHP.jfif](https://cdn.hashnode.com/res/hashnode/image/upload/v1618310307173/aG6EUuagm.jpeg)
**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 JavaTpoint 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 JavaTpoint Site" ?></h1>
</Body>
</Html>