为什么在提供网页时会多次调用index.php?
我遇到了一个问题,首先与我的 PHP 调试器 (xDebug) 设置相关,直到我发现我必须在 IDE (NetBeans) 中单击继续 (F5) 6 次才能显示页面。
注意:我在index.php 中的PHP 的第一行处中断。当然,如果你在index.php中有一个断点,也会发生同样的事情......
有人可以解释这种效果的原因和/或跟踪它的可能性吗?
谢谢 ;)
I had an issue which I first related to my PHP debugger (xDebug) setup until I found out that I have to click Continue (F5) in my IDE (NetBeans) 6 times until the page is displayed.
Note: I break at first line of PHP which is in index.php. Of course same thing happens if you have a breakpoint in index.php...
Can somebody explain the cause of this effect and/or possibilities to trace it?
Thanks ;)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您正在加载的页面包含也作为 Zend 控制器的结果输出的资源,那么调试器将为其中的每一个启动。例如,假设您通过 Zend 控制器提供 javascript 和 CSS 文件,以便它可以出于任何原因向其中注入一些动态块,每次加载使用它们的页面时,都会调用 index.php 并执行各种操作Zend 会完成对 URL 的解析。
当您尝试引用不存在的资源时也会发生这种情况。重写规则的设计使得任何未解析为文件系统中实际文件的请求都将触发 Zend index.php 脚本。
如果您的页面上有任何 Zend 生成的资源或具有指向不存在的资源的链接,那么您将看到 index.php 脚本被多次调用。
顺便说一句,这是您应该只通过 Zend 生成动态内容的一个很好的理由。我遇到过开发人员通过 Zend 控制器提供一切服务的项目。考虑到调用 Zend 框架的重量级和昂贵性,这确实会影响站点的性能。
If the page you're loading contains assets that are also output as the result of a Zend controller then the debugger will start for every one of these. For example, say you're serving javascript and CSS files through a Zend controller so that it can inject some dynamic blocks into them for whatever reason, every time you load a page that uses them, index.php will be invoked and the various things Zend does to resolve the URL will be done.
This will also happen when you're trying to reference a resource that doesn't exist. the rewrite rules in place are designed such that any request that doesn't resolve to an actual file in the filesystem will trigger the Zend index.php script.
If your page has any Zend-generated resources on it or has links to resources that don't exist then you'll see the index.php script get invoked multiple times.
On a side note, this is a good reason why you should only ever generate dynamic content through Zend. I've run into projects where the developer was serving everything through a Zend controller. Given how heavyweight and expensive the Zend framework is to invoke, this can really hammer a site's performance.
我也有同样的问题。这是由于 .htacces 文件中的 RewriteRule 错误引起的。我有类似的东西
用“nevvermind”提到的规则替换它解决了问题(见上文)
I had the same problem. It was caused by wrong RewriteRule in .htacces file. I had something like this
replacing it with the rule mentioned by "nevvermind" fix the problem (see above)