Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/c/59.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在php扩展中检索php流错误_Php_C_Php Extension - Fatal编程技术网

在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); } 上面的代码有时会失败,出现权限被拒绝错误,我需要通

我有一个编写文件的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);        
 }
上面的代码有时会失败,出现
权限被拒绝
错误,我需要通知最终用户

到目前为止,我可以使用
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
并生成自定义错误消息

那么,如何将这两条消息合并为一条消息呢?(哪个更有意义)