PHP 包括 Windows XP 记事本++编辑器 - 导航包含不工作 - 导航消失
我正在创建一个网站,并且有一个选项卡式水平菜单。为了减少当我必须更改菜单时必须编辑的文件数量,我想将导航放在一个单独的文件中,我可以使用 PHP include 语句调用该文件。然而,当我这样做时,导航完全从页面上消失。其余内容保留,并且没有错误消息。 几周来我一直在寻找这个问题的答案,并尝试了我能找到的每个版本的 PHP include 语句。他们都没有工作。 这是最后一次尝试。 我的文件“nav.php”位于名为“testsite”的主目录中名为“includes”的文件夹中 我使用 Windows XP,使用 NotePad++ 作为文本编辑器,并在 Firefox 中进行了测试。 我在任何地方都找不到答案 - 任何帮助将不胜感激。
洛丽安娜
I am creating a website, and have a tabbed horizontal menu. In order to cut back on the number of files I have to edit when I have to make changes to the menu I want to put the navigation in a separate file that I can call using a PHP include statement. When I do this, however, the nav disappears entirely from the page. The rest of the content remains, and there are no error messages.
I have been looking for answers for this for weeks, and have tried every version of the PHP include statement that I could find. None of them worked.
This was the last attempt.
I have the file "nav.php" in a folder named "includes" in a main dir called "testsite"
I use Windows XP, use NotePad++ as my text editor, and have been testing in Firefox.
I can't find an answer anywhere - any help would be appreciated.
Lorianna
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
看来 PHP 没有被解析,您是否尝试过在浏览器中查看页面的源代码?尝试查看您的 PHP 命令是否按原样显示在那里。您在浏览器中调用的主页的扩展名是什么?您是否像 http://localhost/abc.php 使用它?您使用什么网络服务器?
It seems like that the PHP isn't being parsed, have you tried viewing the source of the page in the browser? Try to see if your PHP command shows up in there as it is. What is the extension of your main page that you are calling in the browser? Are you using it like http://localhost/abc.php ? What web server are you using?
我大胆地假设您的 PHP 安装已禁用或抑制了错误。我建议打开它们。
本地服务器
如果您安装在本地计算机上,您可以编辑 php.ini 文件并调整以下行:
不要在
|
之间的垂直管道周围放置空格code>E_ALL 和E_STRICT
或 PHP 将不正确地解析该行并禁用错误。 请务必重新启动 Apache,以便传播 php.ini 中的任何更改。远程服务器
如果您在远程服务器上运行脚本并且无法直接更改 ini 文件,您可以通过将以下内容添加到脚本顶部(在任何包含之前)来在运行时启用错误报告:
error_reporting(-1);
不幸的是,致命错误(括号不匹配等)无法使用运行时开关检测到,因为脚本无法编译。不过,当页面的其余部分显示时,运行时错误开关将捕获丢失的
include()
。进一步阅读
I'm boldly presuming that errors are disabled or suppressed by your PHP installation. I would advise turning them on.
Local Server
If your installation is on your local machine, you can edit the php.ini file and adjust the following lines:
Do not put spaces around the vertical pipe
|
betweenE_ALL
andE_STRICT
or PHP will parse the line improperly and disable errors. Be sure to restart Apache in order to propagate any changes in php.ini.Remote Server
If you are running your script on a remote server and cannot change the ini file directly, you may be able to enable error reporting at runtime by adding the following to the top of your script (before any includes):
error_reporting(-1);
Unfortunately, fatal errors (mismatched brackets, etc.) cannot be detected with the runtime switch because the script does not compile. As the rest of your page displays, though, the runtime error switch will catch a missing
include()
.Further Reading