Jump to content

How to parse PHP in html


drums

Recommended Posts

That's the html tag

<?php echo date(Y); ?>

that I used so not sure what you mean. Shouldn't there be something to tell it to pars php?

Examples of sites on same server (the 2nd link copyright is next to Veitch Law and not the SEO one and all the other pages on that site are hard coded)

http://do-rightweb.com

http://waduidefense.com/links.html

Ah, you're wanting to force the html page to parse as php?  You can do this in .htaccess, yes, add this line:

 

AddType application/x-httpd-php .html

 

If that doesn't work, here's a handful of other methods:

 

http://www.velvetblues.com/web-development-blog/how-to-parse-html-files-as-php/

 

This will make the server treat any file with the .html extension as if it had the .php extension.

If you look at the source code you'll see that it's printing "Copyright © <?php echo date("Y"); ?> - The Veitch Law Firm – All Rights Reserved" - which means that the page is not being parsed as PHP.  Either the functionality is disabled on your server, or you might need to try one of the other methods on that link I sent.

  • 2 months later...

I have tried the htaccess lines in the suggested link (good information).  But I still can't get the PHP tags to work in HTML.

 

I am using GoDaddy Deluxe with Linux Grid & PHP5. (I think this is new and different from the godaddy example in the referenced link).  I think the Deluxe Grid uses the "cgi" part and the php5 is a little different than the other php.

If I leave the cgi off .php files still work

If I leave the "5" off the php the .php files still work

If I add any AddType then the .html files don't work

 

See the following test pages:

http://hexpanse.com/dev/phpworking.php (works)

http://hexpanse.com/dev/phpworking.html (not working)

http://hexpanse.com/dev/layoutwithphp001.php (php gives syntax error on <?MLS version tag)

I am using the following .htaccess file:

AddType image/svg+xml .svg .svgz

AddEncoding x-gzip .svgz

AddHandler x-httpd-php5-cgi .php

AddHandler x-httpd-php-cgi .php4

I got the last two php lines from this GoDaddy support page:

http://community.godaddy.com/help/article/1082

I believe that I should be using php tags inside of .html files, and not the other way around.

 

- Go Daddy support says don't do customer support for help with running scripts, and referee me to the help/support pages.  Some of the other support posts there are using different set ups.  But here is one that is close:

http://community.godaddy.com/groups/web-hosting/forum/topic/php-using-html-file-extension/#post-95463

 

Please advise  - thanks you for any help!

 

Troy McGee

[email protected]

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.