{"id":1600,"date":"2019-02-08T10:35:53","date_gmt":"2019-02-08T10:35:53","guid":{"rendered":"https:\/\/blog.hostinger.io\/support\/2019\/02\/08\/1583190-how-to-parse-php-in-html-files\/"},"modified":"2026-10-29T15:09:17","modified_gmt":"2026-10-29T15:09:17","slug":"1583190-how-to-parse-php-in-html-files","status":"publish","type":"post","link":"https:\/\/www.hostinger.com\/support\/1583190-how-to-parse-php-in-html-files\/","title":{"rendered":"How to parse PHP in HTML files"},"content":{"rendered":"<p>Parse PHP in HTML files at Hostinger by adding an AddHandler directive to your website&rsquo;s .htaccess file, so the server processes PHP code inside .html and .htm files. Back up the .htaccess file first, then add the directive with the File Editor.<\/p><p class=\"no-margin\">PHP is a powerful scripting language used for creating dynamic web applications. Typically, PHP files have a <b>.php<\/b> extension, allowing the server to recognize and process them accordingly. However, there are situations where you might want to embed PHP code directly within an HTML file, such as for integrating dynamic content or executing specific functions within the HTML structure.<\/p><p class=\"no-margin\">To parse PHP code in HTML files, inform the server that the <b>.html<\/b> and <b>.htm<\/b> files contain PHP code by following these steps:<\/p><h2 id=\"h_2f87b36c69\">Step 1 &ndash; Preparations<\/h2><p class=\"no-margin\">Create a <b>backup<\/b> of your .htaccess file before proceeding. An easy way of doing it is by copying the file and renaming it, for example, to <b>.htacces-backup<\/b> using the <b><a data-click-id=\"hgr-post-content-link-file-manager\" class=\"intercom-content-link\" href=\"\/support\/4548688-basic-actions-in-the-file-manager-in-hostinger\/\" target=\"_blank\" rel=\"noopener\">File Manager<\/a><\/b>.<\/p><p class=\"no-margin\">If the file is not present in the <b>public_html<\/b> folder of your website, <b><a data-click-id=\"hgr-post-content-link-create-it\" class=\"intercom-content-link\" href=\"\/support\/1583307-how-to-create-an-htaccess-file-at-hostinger\/\" target=\"_blank\" rel=\"noopener\">create it<\/a><\/b>.<\/p><h2 id=\"h_05a7be0984\">Step 2 &ndash; Edit the .htaccess File<\/h2><p class=\"no-margin\">Next, open the <b>.htaccess<\/b> file using the <b><a data-click-id=\"hgr-post-content-link-file-editor\" class=\"intercom-content-link\" href=\"\/support\/7949267-how-to-use-the-file-editor-at-hostinger\/\" target=\"_blank\" rel=\"noopener\">File Editor<\/a><\/b> and add the following directive to the <b>.htaccess<\/b> file:<\/p><pre><code>AddHandler application\/x-httpd-lsphp .htm .html<\/code><\/pre><p class=\"no-margin\">After saving this change, you can now embed PHP code directly within your HTML markup.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Parse PHP in HTML files at Hostinger by adding an AddHandler directive to .htaccess so the server runs PHP code inside .html and .htm files.<\/p>\n","protected":false},"author":581,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"include_on_kodee":true,"footnotes":""},"categories":[230],"tags":[],"class_list":["post-1600","post","type-post","status-publish","format-standard","hentry","category-php-advanced"],"hreflangs":[{"locale":"en-US","link":"https:\/\/www.hostinger.com\/support\/1583190-how-to-parse-php-in-html-files","default":1},{"locale":"fr-FR","link":"https:\/\/www.hostinger.com\/fr\/support\/1583190-comment-analyser-php-dans-les-fichiers-html-chez-hostinger","default":0},{"locale":"id-ID","link":"https:\/\/www.hostinger.com\/id\/support\/1583190-bagaimana-caranya-membuat-parsing-php-di-file-html-di-hostinger","default":0},{"locale":"pt-BR","link":"https:\/\/www.hostinger.com\/br\/support\/1583190-como-executar-php-em-arquivos-html-hostinger","default":0},{"locale":"uk-UA","link":"https:\/\/www.hostinger.com\/ua\/support\/1583190-\u044f\u043a-\u0440\u043e\u0437\u0456\u0431\u0440\u0430\u0442\u0438-php-\u0432-html-\u0444\u0430\u0439\u043b\u0430\u0445-hostinger","default":0}],"include_on_kodee":true,"_links":{"self":[{"href":"https:\/\/www.hostinger.com\/support\/wp-json\/wp\/v2\/posts\/1600","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.hostinger.com\/support\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.hostinger.com\/support\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.hostinger.com\/support\/wp-json\/wp\/v2\/users\/581"}],"replies":[{"embeddable":true,"href":"https:\/\/www.hostinger.com\/support\/wp-json\/wp\/v2\/comments?post=1600"}],"version-history":[{"count":4,"href":"https:\/\/www.hostinger.com\/support\/wp-json\/wp\/v2\/posts\/1600\/revisions"}],"predecessor-version":[{"id":23466,"href":"https:\/\/www.hostinger.com\/support\/wp-json\/wp\/v2\/posts\/1600\/revisions\/23466"}],"wp:attachment":[{"href":"https:\/\/www.hostinger.com\/support\/wp-json\/wp\/v2\/media?parent=1600"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.hostinger.com\/support\/wp-json\/wp\/v2\/categories?post=1600"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.hostinger.com\/support\/wp-json\/wp\/v2\/tags?post=1600"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}