当前位置:网站首页>Exec function of PHP

Exec function of PHP

2022-06-10 22:05:00 Sleepy snail

  One 、 Modify the configuration file

Create a new one php file

<?php

$command = "pwd"; //ls yes linux Directory under , The order of the document 

exec($command,$array); // Carry out orders 

print_r($array);

?>

Enter the command to execute

php ./test.php

Exception found

This is because in the php Is prohibited in the configuration file of exec Function operation , Therefore, you need to modify the configuration file , Use the following code to locate the configuration file

php -i|grep ini

Go to configuration file , take exec Function delete

  restart php-fpm

service php-fpm restart

Then it is found that it can work normally  

  Two 、exec function

exec ( string $command [, array &$output [, int &$return_var ]] );

exec There are three parameters , The second and third parameters are not required .

The first parameter is the command to execute , The second parameter stores the output of the command execution , The third parameter returns the execution status .

原网站

版权声明
本文为[Sleepy snail]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/161/202206102044070630.html