在php扩展中检索php流错误
我有一个编写文件的PHP扩展在php扩展中检索php流错误,php,c,php-extension,Php,C,Php Extension,我有一个编写文件的PHP扩展 stream = php_stream_open_wrapper(file_path, "a", REPORT_ERRORS | IGNORE_URL_WIN, NULL); if (stream == NULL) { zend_error(E_WARNING, "Fail to open file stream of %s!", file_path); } 上面的代码有时会失败,出现权限被拒绝错误,我需要通
stream = php_stream_open_wrapper(file_path, "a", REPORT_ERRORS | IGNORE_URL_WIN, NULL);
if (stream == NULL)
{
zend_error(E_WARNING, "Fail to open file stream of %s!", file_path);
}
上面的代码有时会失败,出现权限被拒绝
错误,我需要通知最终用户
到目前为止,我可以使用REPORT\u ERRORS
标志,让PHP直接打印流函数中的错误
<b>Warning</b>: Unknown: failed to open stream: Permission denied in <b>Unknown</b> on line <b>0</b><br />
<b>Warning</b>: Fail to open file stream of /opt/rasp/log/plugin/plugin20171219.log! in <b>Unknown</b> on line <b>0</b><br />
警告:未知:无法打开流:第0行未知中的权限被拒绝
警告:无法打开/opt/rasp/log/plugin/plugin20171219.log的文件流!在第0行的未知位置
由于PHP中似乎不存在像peror/GetLastError
这样的函数,因此我不能只执行snprintf
并生成自定义错误消息
那么,如何将这两条消息合并为一条消息呢?(哪个更有意义)