Home > Backend Development > PHP Tutorial > PHP executes external commands with backtick_PHP tutorial

PHP executes external commands with backtick_PHP tutorial

WBOY
Release: 2016-07-13 09:57:24
Original
1178 people have browsed it

PHP uses backticks to execute external commands

For example:

echo `whoami`;

// Export the database, the folder to be imported must have writable permissions, and the content after -u -p must be written immediately

The code is as follows:

echo `mysqldump -h localhost -u$DbUser -p$DbPwd --default-character-set=utf8 $DbName > /var/$dumpFileName`;

Other uses of backticks

1

2

3

4

5

6

7

8

9

10

#使用反撇号,暗示作为命令来执行

$result=`date`;

echo "

the server timestamp is: $result

";

 

echo "


";

#使用shell_exec()

$result1=shell_exec("date");

echo "

the server timestamp is: $result1

";

?>

1 2

3

4 5

67 8 9 10
#Use a backtick to imply execution as a command $result=`date`;
echo "

the server timestamp is: $result

"; echo "
"; #Use shell_exec() $result1=shell_exec("date"); echo "

the server timestamp is: $result1

"; ?>
The output results are as follows: the server timestamp is: Current date: 2009/06/30 Enter the new date: (year, month, day) http://www.bkjia.com/PHPjc/983322.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/983322.htmlTechArticlePHP uses backticks to execute external commands. For example: echo `whoami`; // Export database, file to be imported The folder must have writable permissions, and the content after -u -p must be written next to the code as follows...
Related labels:
php
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