Why php tag is not working in html file?

Your web server will server the HTML page as is. It will only parse the HTML as best as it can. If you rename your page with a PHP extension, the web server will parse it using the PHP interpreter and that is when PHP will be interpreted. Also as Fred points out in the comments you can tell Apache to treat HTML as PHP.

Leave a Comment