【问题标题】:php include not working on my html [duplicate]php包括不适用于我的html [重复]
【发布时间】: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

【问题讨论】:

  • 首先将 &lt;? 更改为 &lt;?php
  • ^ 最好避免使用短打开标签,因为默认情况下不启用它并且通常是一种不好的做法。
  • 按照 Jeff 的说法检查开始标签,并检查脚本是否存在以及到它的路径是否正确。

标签: php linux apache centos


【解决方案1】:

尝试&lt;?php include 'webcss.php' ?&gt; 而不是&lt;? include 'webcss.php' ?&gt;,因为正如 php 文档中所说,不鼓励这样做

【讨论】:

  • &lt;? 是短标签语法,它完全有效 php.net/manual/en/language.basic-syntax.phptags.php - 他们可能没有在他们的系统上启用它们。
  • 我知道,但正如文档中所说,“这是不鼓励的”
  • 那么你的 "its not include 'webcss.php' ?>" 语句解释为告诉他们它是“错了”,事实并非如此。它可能只是没有启用。
  • 是的,也许我的句子中的语法不正确,我改变了它;)
猜你喜欢
  • 2014-03-07
  • 2021-02-23
  • 1970-01-01
  • 2017-01-23
  • 2017-01-22
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多