确定文件的文件包含
有没有办法确定对特定文件调用 require_once 或任何其他包含方法的次数?我遇到了某种包含错误的无限循环问题,现在已经消失了,但我想确定我没有过度包含文件。
Is there a way to determine how many times require_once or any other inclusion method is being called on a specific file? I had an infinite loop issue with some kind of inclusion error, it's gone now, but I'd like to be certain I'm not excessively including files.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我会使用文本搜索软件,该软件将显示您网站上所有文件中出现的所有页面名称。这将返回引用它的任何 require、include 等以及它所在的文件。大多数优秀的 IDE 都会执行此操作。
I would use a text search software that will show me all occurrences of the page name across all the files on your site. This would return any require, include, etc that references it, and the file it is in. Most good IDE's will do this.
我的简单想法是在服务器上使用文本文件...例如
extern.php
index.php
这将在每次包含
extern.php
文件时打印出“include-counter”。结果已存储在文本文件count.txt
中。注意:不要使用相对文件路径(就像我在示例中所做的那样),因为脚本可能会从不同的目录调用。
My simple idea using text file on server... for example
extern.php
index.php
This will print out "include-counter" on every include of
extern.php
file. Result has been stored in text filecount.txt
.Note: Don't use relative file path (like I did in example) because script may be called from different directories.