<? Php tutorial $ test = "ls/tmp/test"; $ out = shell_exec ($ test); echo $ out;?>
Popen, passthru, proc_open, and shell_exec return the following results:
[Root @ krlcgcms01 shell] # php test. php 1001.log 10.log 10.tar.gz aaa.tar.gz mytest test1101 test1102 weblog_2010_09 I can find these functions and execute commands in linux. I 'd like to add more.
In general, php is rarely used to execute linux commands, but in special cases, you may use these functions. I used to know that there are two functions that can execute linux commands: exec and shell_exec. In fact, there are a lot of functions. The following six functions are introduced in combination with the manual content.
1. exec Function
<? Php $ test = "ls/tmp/test"; // ls is the directory for querying files in linux. The command exec ($ test, $ array) of the file ); // execute the command print_r ($ array);?>
The returned results are as follows:
[Root @ krlcgcms01 shell] # php. /exec. php array ([0] => 1001.log [1] => 10.log [2] => 10.tar.gz [3] => aaa.tar.gz [4] => mytest [5] => test1101 [6] => test1102 [7] => weblog_2010_09)