【发布时间】:2017-06-01 13:27:17
【问题描述】:
现在我正在将我的网站迁移到网站无法正常运行的新服务器。在我调试问题后,它是由于“php include not working”。
所以我做了一些测试来发现问题。为了那个原因。我只是用包含标签创建简单的 html 文件
文件名:test1.php 文件内容:
<html lang="en">
<? include 'webcss.php' ?>
</html>
新服务器:通过cli执行文件
[root@localhost test]# php test1.php
<html lang="en">
<? include 'webcss.php' ?>
</html>
[root@localhost test]#
现有服务器:执行相同的 cli 命令。它显示了输出。
[root@www test]# php test1.php
<html lang="en">
<link rel="stylesheet" href="http://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.4.0/css/font-awesome.min.css"> <!-- TO SHOW ARROWS -->
<!-- FONTS -->
<link href='http://fonts.googleapis.com/css?family=Lato:400,300,900,700' rel='stylesheet' type='text/css'>
<link rel="stylesheet" type="text/css" href="style/font-awesome.min.css" />
<!-- //FONTS -->
<!-- JQUERY CSS -->
<link rel="stylesheet" type="text/css" href="style/jquery/flexslider.css" />
<!-- //JQUERY CSS -->
<!-- ANIMATE CSS -->
<link rel="stylesheet" type="text/css" href="style/animate/animate.css" />
<!-- //ANIMATE CSS -->
<!-- SWITCH COLOR RIGHT PANEL CSS -->
<link rel="stylesheet" type="text/css" href="style/switch.color.css" />
<!-- //SWITCH COLOR RIGHT PANEL CSS -->
<!-- CSS -->
<link rel="stylesheet" type="text/css" href="style/bootstrap/bootstrap.min.css" />
<link rel="stylesheet" type="text/css" href="style/style.css" />
<!-- //CSS -->
<!-- THEMES COLOR STYLE -->
<link rel="stylesheet" type="text/css" href="style/template_bg/light.background.css" />
<link rel="stylesheet" type="text/css" href="style/template_color/yellow.color.css" />
<link rel="stylesheet" type="text/css" href="style/template_color/turquoise.color.css" />
<link rel="stylesheet" type="text/css" href="style/template_color/pink.color.css" />
<link rel="stylesheet" type="text/css" href="style/template_color/purple.color.css" />
<link rel="stylesheet" type="text/css" href="style/template_color/green.color.css" />
<link rel="stylesheet" type="text/css" href="style/template_color/red.color.css" />
<link rel="stylesheet" type="text/css" href="style/template_color/blue.color.css" />
<link rel="stylesheet" type="text/css" href="style/template_color/lightgreen.color.css" />
<link rel="stylesheet" type="text/css" href="style/template_color/lightred.color.css" />
<!-- //THEMES COLOR STYLE -->
</html>
[root@www test]#
两台服务器的硬件、操作系统和 php 版本相同。我不知道新服务器上没有运行相同代码的原因是什么。
请有人帮忙解决这个问题。这样我就可以将我的网站移动到新的产品数据中心。
注意:我使用 phpinfo 验证了两台服务器上的 php 设置。两者都是一样的。
我不知道我需要检查哪些参数。
操作系统:CentOS 7
PHP : 5.4.16
【问题讨论】:
-
首先将
<?更改为<?php -
^ 最好避免使用短打开标签,因为默认情况下不启用它并且通常是一种不好的做法。
-
按照 Jeff 的说法检查开始标签,并检查脚本是否存在以及到它的路径是否正确。