Using exec to call system commands in PHP

不言
Release: 2023-03-24 20:18:02
Original
6215 people have browsed it

This article mainly introduces the use of exec to call system commands in PHP. It has certain reference value. Now I share it with everyone. Friends in need can refer to it

ØQuestion: How to execute System commands or execute other files

ØMethod:

1,ModifyPHP.ini

disable_functions = exec

2,Modify permissions

Modify the script to be executed

chmod 777 home/ -R

If other files are executed, the permissions of the corresponding files and all directories above them should be changed to executable mode

3,Debugging

If the script execution fails, use the pipeline command, use 2>&1, the command will output the error during shell execution to the $output variable, and output the variable to analyze the error message

For example:

exec('convert a.jpg b.jpg', $output, $return_val);
Copy after login

Change to:

exec('convert a.jpg b.jpg 2>&1', $output, $return_val); print_r($output);
Copy after login

Related recommendations:

php uses gearman for task distribution


The above is the detailed content of Using exec to call system commands in PHP. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!