超越PHP PHP动态 | 经典文章 | CLASS | 相关下载 | 常见问题 | FORUM | WIKI | 在线手册
Site search:    
<错误控制运算符加一/减一运算符>
Last updated: Fri, 22 Jun 2007

执行运算符

PHP 支持一个执行运算符:反引号(``)。注意这不是单引号!PHP 将尝试将反引号中的内容作为外壳命令来执行,并将其输出信息返回(例如,可以赋给一个变量而不是简单地丢弃到标准输出)。使用反引号运算符“`”的效果与函数 shell_exec() 相同。

<?php
$output
= `ls -al`;
echo
"<pre>$output</pre>";
?>

注: 反引号运算符在激活了 安全模式 或者关闭了 shell_exec() 时是无效的。

参见函数 popen()proc_open() 及手册中“程序执行函数”和“在命令行中使用 PHP”的有关章节。




add a note add a note User Contributed Notes
执行运算符
reed-NO at SPAM-zerohour dot net
13-Mar-2002 04:45
When a program is run using backticks, and the user cancels page loading (if your program is taking too long!), the shell running the program (the one in the backticks) may continue indefinitely on the server. I do not know if this is a bug, or just a danger of using this feature.  (It may depend on the way the browser "cancels" the request -- it was a problem on both IE and OmniWeb for the Mac).  Beware!

<错误控制运算符加一/减一运算符>
 Last updated: Fri, 22 Jun 2007
view source | feedback | send page | sitemap | aboutus   
Copyright ® 2002-2003 PHPE.NET. All rights reserved
Last updated:2002-11-22