【问题标题】:php - include_once seems to print the desired page into the htmlphp - include_once 似乎将所需的页面打印到 html 中
【发布时间】:2012-04-21 21:50:26
【问题描述】:

我的问题是我尝试使用 include_once(); 包含一个类,但它没有包含所需的文件,而是将文件中的代码直接打印到源 html 中,因此代码出现在我的网页上。

这是代码:

<?
include_once('php/class.loadClients.php');
$client = new loadClient();
$client->connect();
?>

我不确定它为什么要这样做,因为我在此页面的其他地方使用了 include_once(); 并且效果很好:

include_once('php/class.register.php');

提前致谢!

【问题讨论】:

    标签: php html include


    【解决方案1】:

    打开php/class.loadClients.php,并在其开头添加&lt;?

    【讨论】:

      【解决方案2】:

      补充 Paulpro 的答案:如果他的解决方案不起作用,您的服务器可能没有启用短标签(&lt;? vs &lt;?php)。使用完整的&lt;?php 标签。

      【讨论】:

      • 这应该是一条评论。
      猜你喜欢
      • 2016-12-05
      • 2016-03-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-04-07
      相关资源
      最近更新 更多