Home > Backend Development > PHP Tutorial > Things to note when calling shell commands in PHP

Things to note when calling shell commands in PHP

WBOY
Release: 2016-07-29 09:16:02
Original
1120 people have browsed it

Interested friends can refer to the precautions for calling the shell command in PHP.

escapeshellarg ( string $arg )
can be used for PHP security and will filter out some special characters present in arg. If

contains Chinese characters in the input parameters and passes them to escapeshellarg, they will be filtered out.

escapeshellcmd ( string $command )
escapeshellcmd() function will escape all shell metacharacters in the command to complete the work. These metacharacters

include: # & ; ` , | * ? ~ < > ^ ( ) [ ] { } $ \.

exec ( string $command [, array &$output [, int &$return_var]] )
Execute the defined command command. If the array output is defined, the output result will be transferred to the output
,

The return value of the execution result is stored in return_var.

passthru ( string $command [, int &$return_var] )
Similar to exec and system, the returned value is raw data, such as binary data, such as pictures.

shell_exec (string $cmd)
Execute the command cmd through the shell, and the complete string is used as the return value.

system ( string $command [, int &$return_var] )
The return value after executing the command command. If php is running in server mode, the system will try to automatically refresh the output cache of the

web server.

Copyright Statement: This article is an original article by the blogger and may not be reproduced without the blogger's permission.

The above introduces the precautions for calling shell commands in PHP, including the relevant aspects. I hope it will be helpful to friends who are interested in PHP tutorials.

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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template