开发者

Dirty errors with PHP popen()

I call a file with popen():

$fp = @popen("/usr/bin/openssl ...");

the specific details don't matter, but what happens here is that when I run the command I receive these errors on a Windows CMD:

The开发者_如何学C system cannot find message text for message number 0x3 in the message file for System.

I know that the file don't exist on Windows, but why doesn't @ silence the errors? My library just tries a few different ways to achieve the same thing.


This is not a error message issued by PHP, so PHP's error suppression won't apply.

You'll have to check whether you can run the operation beforehand or suppress the output of system errors.

For suppressing, 2>NUL should work, as you say. Wouldn't it be better though to test whether the file exists at all? On a Windows machine, your executable is most probably not located in /usr/bin/openssl.

if (file_exists("/usr/bin/...."))
 popen(".....");


Here's the answer I found:

I just wrote " 2>NUL" in the end of the CMD call to make all Windows errors to disappear.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜