Home > Backend Development > PHP Tutorial > Why does php execute shell and return a value of 1?

Why does php execute shell and return a value of 1?

WBOY
Release: 2016-07-06 13:52:12
Original
1327 people have browsed it

<code>$cmd = system("wget http://la-lg.hostus.us/500MB.test",$r);
echo $r;</code>
Copy after login
Copy after login

?>

It can be executed successfully, but the printed value is 1. Logically speaking, isn’t it normal? Nothing but mistakes

Reply content:

<code>$cmd = system("wget http://la-lg.hostus.us/500MB.test",$r);
echo $r;</code>
Copy after login
Copy after login

?>

It can be executed successfully, but the printed value is 1. Logically speaking, isn’t it normal? Nothing but mistakes

Let’s take a look at what the official documentation says:

Returns the last line of the command output if successful, returns FALSE if failed

Look at the English version again:

Returns the last line of the command output on success, and FALSE on failure.

In fact, both of these statements are prone to ambiguity. The correct understanding should be that
returns the exit code of the command
if successful, that is,

<code>exit(code)</code>
Copy after login

in code.
In most cases, exit(0) means there is no error. However this does not mean everything.
The specific needs are under the corresponding commandman wget
The following are the results:

<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>
Copy after login

So equal to 0 does represent success, while equal to 1 represents an error.
Did your file really download successfully?

What does -1 mean?

500M file? It’s timed out

Related labels:
php
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template