Pra*_*ant 3 php webpage shtml file include
我有一个shtml文件index.shtml,其中我想包含一个PHP文件,它执行一些编程并返回HTML数据.我试图包含我的PHP文件,但我不知道该怎么做,我试过以下但没有任何工作,
以下行只是打印错误," [处理此指令时发生错误] ":
<!--#include file="/SSI/test.php"-->
Run Code Online (Sandbox Code Playgroud)
这一行显示一些垃圾字符:
<!--#include virtual="/SSI/test.php"-->
Run Code Online (Sandbox Code Playgroud)
此行无效并显示.shtml页面中的命令
<?PHP
include("/SSI/test.php");
?>
Run Code Online (Sandbox Code Playgroud)
谢谢
小智 8
如果除了您提到的有关流量的内容之外没有特别的原因使用.shtml,您可以在.htaccess文件中更改其处理:
<Files *.shtml>
ForceType application/x-httpd-php
</Files>
Run Code Online (Sandbox Code Playgroud)
或者您可以特别指定该文件:
<Files filename.shtml>
ForceType application/x-httpd-php
</Files>
Run Code Online (Sandbox Code Playgroud)
这将告诉服务器解析.shtml,就像它是.php文件一样,因此应该处理任何PHP命令,例如include语句.无需更改文件扩展名.