使用OB捕获错误?

发布于 2024-09-13 16:37:41 字数 450 浏览 2 评论 0原文

这是一个例子。是否可以保存输出缓冲区。我想缓存它要输出的内容。

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

无边思念无边月 2024-09-20 16:37:41

您是否尝试查看错误日志?根据服务器的不同,您可以在存储该信息的 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

情场扛把子 2024-09-20 16:37:41

我想您可能会想到 此评论中的内容 在 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文