使用OB捕获错误?
这是一个例子。是否可以保存输出缓冲区。我想缓存它要输出的内容。
header('Content-type: text/css');
ob_start("compress");
function compress($buffer) {
$buffer = preg_replace('!/\*[^*]*\*+([^/][^*]*\*+)*/!', '', $buffer);
$buffer = str_replace(array("\r\n", "\r", "\n", "\t", ' ', ' ', ' '), '', $buffer);
return $buffer;
}
include('layout.css');
include('pages.css');
include('form.css');
include('global.css');
ob_end_flush();
Here is an example. Is it possible to save the output buffer. I would like to cache what its going to output.
header('Content-type: text/css');
ob_start("compress");
function compress($buffer) {
$buffer = preg_replace('!/\*[^*]*\*+([^/][^*]*\*+)*/!', '', $buffer);
$buffer = str_replace(array("\r\n", "\r", "\n", "\t", ' ', ' ', ' '), '', $buffer);
return $buffer;
}
include('layout.css');
include('pages.css');
include('form.css');
include('global.css');
ob_end_flush();
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您是否尝试查看错误日志?根据服务器的不同,您可以在存储该信息的 vhost 文件中找到此信息。您的第一行操作应该是查看 Apache 错误日志,因为它们应该显示任何错误。
例如,我将我的设置为(在 Ubuntu 上)
/var/log/apache2/sitename.error.log
Did you try looking through the error logs? Depending on the server you can find this information out in the vhost file where it is stored. This should be your first line of action is look through the Apache error logs, as they should show up any errors.
For instance, I set mine to (on Ubuntu)
/var/log/apache2/sitename.error.log
我想您可能会想到 此评论中的内容 在 set_error_handler 文档页面上:
但是,我会赞同 premiso 关于使用错误日志的评论。根据我的经验,覆盖 error_handling 是不直观的,并且通常会导致更多的复杂性而不是有用性。
请参阅:
两者都是PHP_INI_ALL,所以它们可以是使用 ini_set() 在脚本中或在 .htaccess 以及全局配置位置中设置。
I think you might be thinking of something like in this comment on the set_error_handler documentation page:
However, I would second premiso's comment about using error logs instead. Overriding error_handling is unintuitive and usually leads to more complication than usefulness in my experience.
See:
Both are PHP_INI_ALL, so they can be set in script using ini_set(), or in .htaccess, as well as global configuration locations.