PHP怎样执行BAT文件,或者其他可执行文件??

吴孟超 2011-01-23 10:59:25
PHP怎样执行BAT文件,或者其他可执行文件??如果能下载直接运行也行
...全文
992 5 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
tottyandbaty 2011-01-25
  • 打赏
  • 举报
回复
exec函数,这个受系统限制,如果开启了安全模式,这个将不起作用
浴火_凤凰 2011-01-25
  • 打赏
  • 举报
回复
exec system百度一下
ihefe 2011-01-24
  • 打赏
  • 举报
回复
exec system passthru
skyaspnet 2011-01-24
  • 打赏
  • 举报
回复
system
(PHP 4, PHP 5)

system — Execute an external program and display the output

说明
string system ( string $command [, int &$return_var ] )
system() is just like the C version of the function in that it executes the given command and outputs the result.

The system() call also tries to automatically flush the web server's output buffer after each line of output if PHP is running as a server module.

If you need to execute a command and have all the data from the command passed directly back without any interference, use the passthru() function.

参数

command
The command that will be executed.

return_var
If the return_var argument is present, then the return status of the executed command will be written to this variable.


返回值
Returns the last line of the command output on success, and FALSE on failure.

范例

Example #1 system() example

<?php
echo '<pre>';

// Outputs all the result of shellcommand "ls", and returns
// the last output line into $last_line. Stores the return value
// of the shell command in $retval.
$last_line = system('ls', $retval);

// Printing additional info
echo '
</pre>
<hr />Last line of the output: ' . $last_line . '
<hr />Return value: ' . $retval;
?>

skyaspnet 2011-01-24
  • 打赏
  • 举报
回复
相当于调用命令:

exec
(PHP 4, PHP 5)

exec — Execute an external program

说明
string exec ( string $command [, array &$output [, int &$return_var ]] )
exec() executes the given command.

参数

command
The command that will be executed.

output
If the output argument is present, then the specified array will be filled with every line of output from the command. Trailing whitespace, such as \n, is not included in this array. Note that if the array already contains some elements, exec() will append to the end of the array. If you do not want the function to append elements, call unset() on the array before passing it to exec().

return_var
If the return_var argument is present along with the output argument, then the return status of the executed command will be written to this variable.


返回值
The last line from the result of the command. If you need to execute a command and have all the data from the command passed directly back without any interference, use the passthru() function.

To get the output of the executed command, be sure to set and use the output parameter.

范例

Example #1 An exec() example

<?php
// outputs the username that owns the running php/httpd process
// (on a system with the "whoami" executable in the path)
echo exec('whoami');
?>

21,893

社区成员

发帖
与我相关
我的任务
社区描述
从PHP安装配置,PHP入门,PHP基础到PHP应用
社区管理员
  • 基础编程社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧