html to PHP

Problems with the Windows version of XAMPP, questions, comments, and anything related.

html to PHP

Postby wingguy » 21. November 2017 15:17

I have most of my php code saved as html files. The ini file was changed to parse the files to work correctly.
However, I cannot get xampp to do the same. The extension must be php to work.
How can I get xampp to parse html files as php?
Thanks
wingguy
 
Posts: 2
Joined: 21. November 2017 15:13
XAMPP version: 7.1.11
Operating System: windows 7

Re: html to PHP

Postby Nobbie » 22. November 2017 11:51

wingguy wrote:The ini file was changed to parse the files to work correctly.


??

Which ini files? You need to change the Apache configuration (as Apache triggers PHP due to the extension) and Apache is not configured via any ini file?!
You must edit the proper *.conf file, i think either httpd.conf or extra/httpd-xampp.conf and look/edit the following line (search with an editor):

Code: Select all
AddType application/x-httpd-php .php .php3 .php4


Add any extension you need (for example .html and .htm):

Code: Select all
AddType application/x-httpd-php .php .php3 .php4 .html .htm


finally restart Apache.

BUT: i do not recommend this kind of setup, its a waste of ressources, as every HTML file now is running thru PHP interpreter even if there is no PHP inside. You have no option to deny any file from being parsed. You will also get into troubles when uploading your project to any webhoster, as these usually do NOT handle HTML files same as PHP files. It's definately a word wide standard to call PHP files *.php and not *.html.
Nobbie
 
Posts: 13170
Joined: 09. March 2008 13:04

Re: html to PHP

Postby wingguy » 23. November 2017 01:20

Thanks Nobbie. I'll start future projects using the php extension.
I have several sites with html files that handle php just fine. Just have use php from now on.
wingguy
 
Posts: 2
Joined: 21. November 2017 15:13
XAMPP version: 7.1.11
Operating System: windows 7


Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 184 guests