In order to facilitate the majority of candidates to better review, to help the examination network to comprehensively organize the Linux Certification: PHP calls common functions of the Linux system for examination review reference, hope to help students review. PHP calls common Linux functions 1. exec functions & lt ;? Php... "> <LINKhref =" http://www.php100.com//s
In order to facilitate the majority of candidates to better review, to help the examination network to comprehensively organize the Linux Certification: PHP calls common functions of the Linux system for examination review reference, hope to help students review.
PHP calls common functions in Linux
1. exec function
$ Test = "ls/tmp/test"; // ls is the directory for querying files in linux.
Exec ($ test, $ array); // execute the command
Print_r ($ array );
?>
2. system functions
$ Test = "ls/tmp/test ";
$ Last = system ($ test );
Print "last: $ last \ n ";
?>
3. passthru function
$ Test = "ls/tmp/test ";
Passthru ($ test );
?>
4. popen function
$ Test = "ls/tmp/test ";
$ Fp = popen ($ test, "r"); // popen forms a process Channel
While (! Feof ($ fp) {// get something from the Channel
$ Out = fgets ($ fp, 4096 );
Echo $ out; // Print it out
}
Pclose ($ fp );
?>
5. proc_open function
$ Test = "ls/tmp/test ";
$ Arrayarray = array (
Array ("pipe", "r"), // standard input
Array ("pipe", "w"), // standard output content
Array ("pipe", "w") // standard output error
);
$ Fp = proc_open ($ test, $ array, $ pipes); // open a process Channel
Echo stream_get_contents ($ pipes [1]); // why is $ pipes [1], because 1 is the output content
Proc_close ($ fp );
?>
6. proc_open function
$ Test = "ls/tmp/test ";
$ Arrayarray = array (
Array ("pipe", "r"), // standard input
Array ("pipe", "w"), // standard output content
Array ("pipe", "w") // standard output error
);
$ Fp = proc_open ($ test, $ array, $ pipes); // open a process Channel
Echo stream_get_contents ($ pipes [1]); // why is $ pipes [1], because 1 is the output content
Proc_close ($ fp );
?>
7. shell_exec function
$ Test = "ls/tmp/test ";
$ Out = shell_exec ($ test );
Echo $ out;
?>