如何自动删除 FirePHP 的调试语句?
FirePHP 要求我在每个 .php 页面上添加调试函数调用:
require_once('FirePHPCore/FirePHP.class.php');
ob_start();
这在我的本地计算机上不是问题。但我想当我的代码在现实世界中运行时删除/禁用它们。
是否有任何“调试模式”变量可以禁用它们或有工具可以删除它们?
FirePHP
asks me to add debug function call on every .php page:
require_once('FirePHPCore/FirePHP.class.php');
ob_start();
It ist't a problem on my local machine. But I want to remove/disable them when my code is working in real world.
Is there any "debug mode" variable to disable them or tool to remove them?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
注意:如果您删除了 FirePHP 包含调用,但代码中仍然有 FirePHP 日志记录调用,您将收到致命错误!
正确的解决方案是禁用FirePHPCore 0.3:
请参阅API 参考了解更多信息。
应用程序/网站中的所有页面/脚本都应在执行其他操作之前调用中央引导文件。上面的代码应该位于此引导程序文件中,这将允许您在部署时轻松禁用整个应用程序的 FirePHP:
bootstrap.php
~仅供参考,如果使用 FirePHP 1.0 仅在检测到授权客户端时才会发送日志消息,从而无需代码 多于。
NOTE: If you remove the FirePHP include call but still have FirePHP logging calls in your code you will get a fatal error!
The proper solution is to disable FirePHPCore 0.3:
See API reference for more information.
All pages/scripts in your application/website should call a central bootstrap file before doing anything else. The code above should be in this bootstrap file which will allow you to easily disable FirePHP for the entire application when deployed:
bootstrap.php
~FYI, If using FirePHP 1.0 logging messages will only be sent if an authorized client is detected eliminating the need for the code above.
只需定义一个常量
并稍后使用它:
Just define a constant
and use it later:
卡多恩的后续行动:
如果在您的框架中,FirePHP 是可选安装(插件、插件,..),有人最终可能会完全禁用或完全卸载,您可能会考虑检查您的框架核心<中的 FirePHP 类或函数的可用性/em> 通过
class_exists()
或function_exists()
,如果 FirePHP 无法访问,请定义替代函数。这样,您可以避免致命错误,并最终提供一些反馈/输出,例如“FirePHP 不可用”。followup to cadorn:
If in your framework FirePHP is an optional install (addon,plugin,..) someone could eventually dissable or uninstall completely, you might consider to check FirePHP class or functions availability in your frameworks core via
class_exists()
orfunction_exists()
, and in case FirePHP is out of reach, define subsititute functions. That way, you can avoid fatals, and eventually give some feedback/ouput alike "FirePHP not available"..