- System ("/usr/local/bin/webalizer/webalizer");
- ?>
Copy Code
exec () prototype: string exec (String command [, string array [, int return_var]])
The exec () function, like system (), also executes the given command, but does not output the result, but instead returns the last line of the result. Although it returns only the last line of the command result, the second parameter array gives the complete result by appending the result line to the end of the array. So if the array is not empty, it is best to clear it with unset () before calling it. The third parameter can be used to obtain the status code of the command execution only if the second parameter is specified.
Example:
- EXEC ("/bin/ls-l");
- EXEC ("/bin/ls-l", $res);
- # $res is a data, each element represents a row of results
- EXEC ("/bin/ls-l", $res, $RC);
- # The value of the $RC is the status code of the command/bin/ls-l. The case of success is usually 0
- ?>
Copy Code
PassThru () prototype: void PassThru (String command [, int return_var])
PassThru () only invokes the command, does not return any results, but outputs the result of the command directly to the standard output device. So the PassThru () function is often used to invoke programs such as Pbmplus (a tool for processing pictures under Unix, a stream of output binary raw images). It can also get the status code of the command execution.
Example:
- Header ("Content-type:image/gif");
- PassThru ("./ppmtogif hunte.ppm");
- ?>
Copy Code |