Embed php tag within .html extension

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

Embed php tag within .html extension

Postby chandecweng » 05. November 2011 16:09

Hi all, I can not embed php tag within .html extension.

How can I enable it, will it cause by my editor setting( Aptana Studio ) ?

Thanks a lot for provide me the solution.
chandecweng
 
Posts: 17
Joined: 20. July 2011 05:54
Operating System: Window 7

Re: Embed php tag within .html extension

Postby Altrea » 05. November 2011 18:10

Hi chandecweng,

.html files will not be sent through the php parser, that's the reason.

If you want to get php blocks in .html files parsed (which i wouldn't recommend, because there is no good reason for this and the disadvantage will be that even plain html files without php blocks have to go through the php parser unnecessarily), your Apache has to know this.

The setting for this is in your \xampp\apache\conf\extra\httpd-xampp.conf (change lines 20 and 43).
We don't provide any support via personal channels like PM, email, Skype, TeamViewer!

It's like porn for programmers 8)
User avatar
Altrea
AF Moderator
 
Posts: 11926
Joined: 17. August 2009 13:05
XAMPP version: several
Operating System: Windows 11 Pro x64

Re: Embed php tag within .html extension

Postby chandecweng » 06. November 2011 06:11

Altrea wrote:Hi chandecweng,

.html files will not be sent through the php parser, that's the reason.

If you want to get php blocks in .html files parsed (which i wouldn't recommend, because there is no good reason for this and the disadvantage will be that even plain html files without php blocks have to go through the php parser unnecessarily), your Apache has to know this.

The setting for this is in your \xampp\apache\conf\extra\httpd-xampp.conf (change lines 20 and 43).



Hi,Thanks for helping me.

I have change the line 43 like this: AddType text/html .php .phps .html

But I do not know how to change line 20: <FilesMatch "\.php$"> ?

Thanks
chandecweng
 
Posts: 17
Joined: 20. July 2011 05:54
Operating System: Window 7

Re: Embed php tag within .html extension

Postby Altrea » 06. November 2011 12:15

How about
Code: Select all
<FilesMatch "\.(php|html)$">
We don't provide any support via personal channels like PM, email, Skype, TeamViewer!

It's like porn for programmers 8)
User avatar
Altrea
AF Moderator
 
Posts: 11926
Joined: 17. August 2009 13:05
XAMPP version: several
Operating System: Windows 11 Pro x64

Re: Embed php tag within .html extension

Postby webdesign.boston » 11. November 2011 20:05

The way to execute PHP on a .html page is to modify your .htaccess file. This file may be hidden, so depending upon your FTP program you may have to modify some settings to see it. Then you just need to add this line for .html:

AddType application/x-httpd-php .html
Or for .htm
AddType application/x-httpd-php .htm
If you only plan on including the PHP on one page, it is better to setup this way:
<Files yourpage.html>
AddType application/x-httpd-php .html
</Files>
This code will only make the PHP executable on the yourpage.html file, and not on all of your html pages.
Website Design by Affordable Web Design
webdesign.boston
 
Posts: 1
Joined: 11. November 2011 19:49
Location: Boston
Operating System: Windows7


Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 126 guests