문제

Okay, so I'm very new to website design, so please keep that in mind. I've been working on a website (with file extension .shtml), and the time has come to add php code to it. It's only a little code, but it doesn't work on the .shtml website; the php code ends up in the source code as a comment. I was wondering if there was a way to make php code work on an shtml website. Thanks.

도움이 되었습니까?

해결책

Change the .shtml to .php update the include files you probably have and your on your way.

To keep your .shtml add this

AddType application/x-httpd-php .shtml

Keep in mind this will put additional load on your webserver as it will now scan all .shtml for php instead of just .php files

This can be added in the httpd.conf file

다른 팁

You'll need to setup a web server to get this working. Checkout Apache, or http://www.apachefriends.org/en/xampp.html for something very easy to setup. You can't just drop PHP into an html page and expect it to execute, it needs the interpreter.

Write your PHP code as a separate .php file and then include it using SSI, as so:

<!--#include virtual="/path/to/yourfile.php" -->

This worked for me on a hosted website with no changes to .htaccess required. The PHP executes before being included in the .shtml page.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top