Jump to content

I Cant Run Php From Html


rain13

Recommended Posts

HelloI have problem with calling php from htmls,I used example from this site.I would need some suggestions what to do.Direct URL to file, you can see the resulthttp://autoit.pri.ee/test/thisfile.htmlURL to snif ( you can use it to see that file is correct)http://autoit.pri.ee/test/I tried this code.
<html><body><?phpecho "Hello World";?></body></html>

Contact your ISP. Make sure PHP is on from their end.
Link to comment
Share on other sites

You've just solved the problem :)For PHP to work, files need to have .php filenames, unless you use .htaccess to make php run on .html or .blah or .wibble filenames, or any filename you choose.:)

Link to comment
Share on other sites

You've just solved the problem :)For PHP to work, files need to have .php filenames, unless you use .htaccess to make php run on .html or .blah or .wibble filenames, or any filename you choose.:)
I looks good idea,but what I have to exactly type in .htaccess file?I would like example please.Where I should put .htaccess file? in server root or in directory I have my html?Thanks
Link to comment
Share on other sites

I'd recommend sticking with using the .php file name extension for PHP files unless you have a good reason. The obvious reason for this is that if you're just learning PHP then it will help to keep things simple. The less obvious reason for this is that you then wouldn't be able to have .html files that don't require any PHP. You'll still be forcing these files to go through the PHP interpreter, adding an unnecessarily overhead.If you've got your mind set on using the .html extension for php files though...Go to the 'www' root (where your html docs are stored), look for a file called .htaccess. If it's there then edit it, otherwise create it. Insert these lines:

RemoveHandler .html .htmAddType application/x-httpd-php .php .htm .html

Bare in mind this is an apache feature and doesn't work on all web servers.

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...