gpt4 book ai didi

php - 在 PHP 中包含不同类型的文件

转载 作者:可可西里 更新时间:2023-11-01 00:12:08 25 4
gpt4 key购买 nike

我接手了一个 PHP 项目,并试图让它在我的开发箱上运行。我是一名开发人员而不是系统管理员,所以我无法让它正常工作。

以前的开发人员使用 .h 文件来包含 PHP。我当前的配置是采用该 .h 文件并包含它而不执行它。我需要在我的 apache 配置中寻找什么(或者是我的 php.ini)?

编辑:

当我阅读下面的评论之一时,点击了一些内容。该代码使用 ASP 样式标签“<?”。我在 php.ini 中打开了该选项,根据 phpinfo(),它已启用,但 apache 仍然只是将代码作为文本包含在内。

我刚刚检查了它并使用完整的开放 PHP 标记“<?php”运行代码修复了问题。话虽如此,我仍然希望它以另一种方式工作。

我在最新版本可用的 Macbook 上运行代码。 PHP 5.2.6、postgresql 8.3 和 apache 2。

代码在登台服务器上运行,但我无法弄清楚它有什么区别。

编辑

Durrr...我没有在 php.ini 中启用 short_open_tags。

最佳答案

问题可能是您包含的 .h 文件只是开始进入 php 代码而没有开始“<?php”标记吗?

来自 include文档:

When a file is included, parsing drops out of PHP mode and into HTML mode at the beginning of the target file, and resumes again at the end. For this reason, any code inside the target file which should be executed as PHP code must be enclosed within valid PHP start and end tags.

关于php - 在 PHP 中包含不同类型的文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/717952/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com