PHP executes 6 functions commonly used in Linux commands

Source: Internet
Author: User

In general, PHP is rarely used to execute Linux commands, but you might use them in special cases. I used to know that there are two functions that can execute Linux commands, one is exec, the other is shell_exec. In fact, there are many, combined with the contents of the manual, introduced the following 6 functions.

1,exec function

 
  
  
  1. <?php
  2. $test = "Ls/tmp/test"; LS is the directory under Linux, the command of files
  3. EXEC ($test, $array); Execute command
  4. Print_r ($array);
  5. ?>

The returned results are as follows:

 
  
  
  1. [Root@krlcgcms01 shell]# php./exec.php
  2. Array
  3. (
  4. [0] => 1001.log
  5. [1] => 10.log
  6. [2] => 10.tar.gz
  7. [3] => aaa.tar.gz
  8. [4] => mytest
  9. [5] => test1101
  10. [6] => test1102
  11. [7] => weblog_2010_09
  12. )




Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.