Precautions for calling shell commands in PHP

Source: Internet
Author: User
: This article mainly introduces considerations for calling shell commands in PHP. For more information about PHP tutorials, see. Notes for calling shell commands in PHP. For more information, see.

Escapeshellarg (string $ arg)
Php security can be used to filter out some special characters in arg. In the input parameter, if

If it contains Chinese characters and is passed to escapeshellarg, it will be filtered out.

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

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

Exec (string $ command [, array & $ output [, int & $ return_var])
Execute the defined command. If the array output is defined, the output result is uploaded to the output,

The returned values of execution results are 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.

Shell_exec (string $ cmd)
Run the command cmd in shell to return the complete string.

System (string $ command [, int & $ return_var])
Returns the value after the command is executed. If php runs in server mode, the system attempts to automatically refresh

The output cache of the web server.

Copyright Disclaimer: This article is an original article by the blogger and cannot be reproduced without the permission of the blogger.

The above describes the precautions for calling shell commands in PHP, including some content. I hope to help some friends who are interested in PHP tutorials.

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.