PHP tags

Need help installing PHP, configuring a script, or configuring a server? Then come on in and post your questions! We'll try to help the best we can!

Moderator: General Moderators

Post Reply
p4pratik
Forum Newbie
Posts: 7
Joined: Tue Jun 12, 2007 2:24 am

PHP tags

Post by p4pratik »

Hi,

Can I use a php tag in a normal HTML file. By this I mean that the file that will be outputted to browser will be a .html file and not a .php file. However, that html file might comprise some <?php?> tags

Please help!!!

Thanking You in advance,


Kind Regards

Pratik
User avatar
dibyendrah
Forum Contributor
Posts: 491
Joined: Wed Oct 19, 2005 5:14 am
Location: Nepal
Contact:

Post by dibyendrah »

Yes you can do that with the apache configuration. If you want to parse PHP tags within the plain html file, you just have to edit configuration file of apache web server.

Just add following line in your httpd.conf file.

Code: Select all

AddType application/x-httpd-php .html
OR

Code: Select all

AddHandler application/x-httpd-php .html
Try any of the above lines.
p4pratik
Forum Newbie
Posts: 7
Joined: Tue Jun 12, 2007 2:24 am

PHP tags

Post by p4pratik »

Hi,

Thank you very much for your immediate response.

I just have to add any 1 of these two lines and get the work done. Is that anything else which i need to do??

Kind Regards

Pratik
p4pratik
Forum Newbie
Posts: 7
Joined: Tue Jun 12, 2007 2:24 am

PHP tags

Post by p4pratik »

Hi Dib,

The solution provided by you worked on my machine. However one doubt.

Since I have apache installed on my machine, I changed the httpd.conf file and things got worked.

But what if I have an ISP who host web sites on an Apache server?
In that case, I will not have any control over the httpd.conf file of the ISP.

I will give the ISP only the pages of my website??

Will that work in that case??

Thanking you in advance

Kind Regards,

Pratik
User avatar
dibyendrah
Forum Contributor
Posts: 491
Joined: Wed Oct 19, 2005 5:14 am
Location: Nepal
Contact:

Post by dibyendrah »

That can be done using .htaccess file.

Look for the file named .htaccess in your public_html folder. If it's not there, using text editor and save it as .htaccess

Now add the the following lines:

Code: Select all

RemoveHandler .html .htm
AddType application/x-httpd-php .php .htm .html
This should work !

To learn about .htaccess file, refer to this page :
http://httpd.apache.org/docs/howto/htaccess.html

Best,
Dibyendra
p4pratik
Forum Newbie
Posts: 7
Joined: Tue Jun 12, 2007 2:24 am

PHP Tags

Post by p4pratik »

Hi,

Thank you once again

Kind regards

Pratik
Post Reply