我第一次在html文档中使用php-include命令,但由于某些原因它无法工作。
我之所以使用php-include,是因为我将几个css、jquery和jv文件链接到我的html文档。
我把所有这些链接都放在我的其他60个html文档中。如果我必须更改或添加任何链接,将很难在所有60个文档中更改它。
所以我在html文档的顶部使用了类似这样的php命令。
<?php
include("http://www.omenaa.ws/html/scripts.html");
?>
这就是我放在scripts.html文件中的内容
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js" type=
"text/javascript">
</script>
<script src="http://bxslider.com/lib/jquery.bxslider.min.js" type="text/javascript">
</script>
<link href="http://bxslider.com/lib/jquery.bxslider.css" rel="stylesheet" type=
"text/css" />
<link rel="stylesheet" type="text/css" href="http://www.omenaa.ws/css/slider.css" />
<script src="http://omenaa.ws/js/jquery.fitvids.js" type="text/javascript">
</script>
<script src="http://api.html5media.info/1.1.5/html5media.min.js" type=
"text/javascript">
</script>
<script type="text/javascript">
// <![CDATA[
$(function() {
$('.bxslider').bxSlider({
nextSelector: '#slider-next',
prevSelector: '#slider-prev',
infiniteLoop: false,
adaptiveHeight:true,
video:true,
nextText: 'Next - I am done!',
prevText: 'I need to go back'
});
});
// ]]>
</script>
<title></title>
</head>
<body>
</body>
</html>
我做错了什么?
i am testing it locally, without xxamp
如果没有解释PHP的引擎,你的计算机就无法执行它。你的计算机上没有内置的支持,你需要一个服务器来解释代码并相应地将其发送到浏览器。
编辑
默认情况下,Xamp安装不会尝试在.html文件中执行php代码,您需要启用对它的支持。最简单的方法之一是打开.htaccess
文件,然后简单地执行:
AddType application/x-httpd-php .html
这将告诉您的服务器像处理php文档一样处理html文档,从而允许执行php代码。
否则,只需将文件从.html
重命名为.php
即可。
包含url需要额外的权限-您相信该远程网站的作者不会将讨厌的php代码放入…您要查找的设置是allow_url_include,默认情况下为0(关闭)。
如果文件是本地文件,则应该使include引用本地文件,而不是url。