Home >Backend Development >PHP Tutorial >PHP uses backticks to execute external commands, php executes external commands_PHP tutorial

PHP uses backticks to execute external commands, php executes external commands_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 09:57:12898browse

PHP uses backticks to execute external commands, php executes 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

Copy code The code is as follows: echo `mysqldump -h localhost -u$DbUser -p$DbPwd --default-character-set=utf8 $DbName > /var/$dumpFileName`;

Other uses of backticks

<&#63;php  
  #使用反撇号,暗示作为命令来执行
  $result=`date`;
  echo "<p>the server timestamp is: $result</p>";

  echo "<hr color=red>";
  #使用shell_exec()
  $result1=shell_exec("date");
  echo "<p>the server timestamp is: $result1</p>";
&#63;>

The output results are as follows:
the server timestamp is: Current date: 2009/06/30 Enter the new date: (year, month, day)

The above is the entire content of this article, I hope you all like it.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/984007.htmlTechArticlePHP uses backticks to execute external commands, and php executes external commands. For example: echo `whoami`; // Export database , the folder to be imported must have writable permissions, and the content after -u -p must be important...
Statement:
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