How to use PHP in HTML ? Last Updated : 22 Mar, 2024 Summarize Comments Improve Suggest changes Share Like Article Like Report In this article, we will use PHP in HTML. There are various methods to integrate PHP and HTML, some of them are discussed below. You can add PHP tags to your HTML Page. You simply need to enclose the PHP code with the PHP starts tag <?php and the PHP end tag ?>. The code wrapped between these two tags is considered to be PHP code, and it will be executed on the server side before the requested file is sent to the client browser. Note: To use PHP in HTML, you have to use the .php extension because In PHP the code is interpreted and run on the server-side. Syntax: <html> <?php echo "welcome to geeksforgeeks" ?></html>Examples to use PHP in HTML Example 1: In this example, we are rendering a simple h2 tag with the help of PHP code. PHP <!DOCTYPE html> <html> <body> <center> <h2> <?php echo "This is PHP code inside html" ?> </h2> </center> </body> </html> Output: PHP in HTML Example Output Example 2: In this example, we are using different PHP code snippet to render on web page. PHP <!DOCTYPE html> <html> <head> </head> <body> <center> <p> <?php echo "Complete <strong>Portal</strong> for Geeks." ?> <br><br> <?php echo 'Explore, learn and grow.' ?> </p> </center> </body> </html> Output: PHP in HTML Example Output How to use PHP in HTML ? Comment More infoAdvertise with us Next Article How to Install PHP on Ubuntu? A aksrathod07 Follow Improve Article Tags : PHP PHP-basics HTML-Questions PHP-Questions Similar Reads How to parse HTML file in PHP ? In this article, we will learn to parse HTML in PHP. What is parsing? Generally parsing is converting one data type to another. It means how we can convert various data types to HTML. For example: Converting string to HTML. Why do we need parsing? To add the dynamic data (HTML content) at a certain 2 min read How to Install PHP on Ubuntu? If you're working with web development on Linux, knowing how to install PHP on Ubuntu is essential. PHP is a popular server-side scripting language used to build dynamic websites, and setting it up on your Ubuntu system is simple. In this guide, we'll walk you through the steps to PHP installation o 5 min read How to Install PHP on Linux? PHP is a popular server-side scripting language that is especially used in web development. If you're working on a Linux environment, whether it's a personal development setup or a production server, you will likely need PHP installed. In this article, we will see the step-by-step guide to install P 2 min read How to prevent XSS with HTML/PHP ? Cross-Site Scripting or XSS is a type of security vulnerability where an attacker gains access to a website and executes a potentially malicious script at the client's side. This is one of the code injections attacks which can be caused by incorrectly validating user data, which usually gets inserte 4 min read How to prevent XSS with HTML/PHP ? Cross-Site Scripting or XSS is a type of security vulnerability where an attacker gains access to a website and executes a potentially malicious script at the client's side. This is one of the code injections attacks which can be caused by incorrectly validating user data, which usually gets inserte 4 min read How to embed PHP code in an HTML page ? PHP is the abbreviation of Hypertext Preprocessor and earlier it was abbreviated as Personal Home Page. We can use PHP in HTML code by simply adding a PHP tag without doing any extra work. Example 1: First open the file in any editor and then write HTML code according to requirement. If we have to a 2 min read Like