<code>$cmd = system("wget http://la-lg.hostus.us/500MB.test",$r);
echo $r;</code>?>
立即学习“PHP免费学习笔记(深入)”;
能成功执行,但是打印的数值是1,按道理来说正常不是1吗?只有错误才会别的
<code>$cmd = system("wget http://la-lg.hostus.us/500MB.test",$r);
echo $r;</code>?>
立即学习“PHP免费学习笔记(深入)”;
能成功执行,但是打印的数值是1,按道理来说正常不是1吗?只有错误才会别的
我们看下官方文档的说法:
成功则返回命令输出的最后一行, 失败则返回 FALSE
再看看英语版:
Returns the last line of the command output on success, and FALSE on failure.
实际上,这两种说法都容易引起歧义,正确的理解应该是
成功则返回命令的退出码
即
<code>exit(code)</code>
中的code。
大部分情况下,exit(0)代表没有错误。然而这并不代表所有。
具体的需要在对应命令下man wget
以下是结果:
<code>EXIT STATUS
Wget may return one of several error codes if it encounters problems.
0 No problems occurred.
1 Generic error code.
2 Parse error---for instance, when parsing command-line options, the .wgetrc or .netrc...
3 File I/O error.
4 Network failure.
5 SSL verification failure.
6 Username/password authentication failure.
7 Protocol errors.
8 Server issued an error response.
With the exceptions of 0 and 1, the lower-numbered exit codes take precedence over higher-numbered ones, when
multiple types of errors are encountered.
</code>所以等于0确实是代表成功,而等于1代表了出错。
你的文件真的下载成功了吗?
-1到底啥意思呢?
500M的文件?超时了吧
PHP怎么学习?PHP怎么入门?PHP在哪学?PHP怎么学才快?不用担心,这里为大家提供了PHP速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号