php二维码扫描插件要调用dll文件,首先想到了system()和exec()函数调用。
php的内置函数exec,system都可以调用系统命令(shell命令),当然还有passthru,escapeshellcmd等函数。
在很多时候利用php的exec,system等函数调用系统命令可以帮助我们更好更快的完成工作。比如前二天笔者在批量处理.rar文件时exec就帮我了大忙了。
今天整理一下常用的调用系统函数发出来和大家分享经验。
注意:要想使用这二个函数php.ini中的安全模式必须关闭,要不然为了安全起见php是不让调用系统命令的。
先看一下php手册对这二个函数的解释:
exec --- 执行外部程式
语法 : string exec ( string command [, array &output [, int &return_var]] )
说明 :
exec( )执行给予的命令command,不过它并不会输出任何东西,它简单的从命令的结果中传...
PHP调用Linux系统的常用函数
例如像 1、exec函数 2、system函数 还有哪些?
1、exec函数
[php]
<?php
$test = "ls /tmp/test"; //ls是linux下的查目录,文件的命令
exec($test,$array); //执行命令
print_r($array);
?>
[/php]
2、system函数
[php]
<?php
$test = "ls /tmp/test";
$last = system($test);
print "last: $last\n";
?>
[/php]
passthru函数
[php]
$test = "ls /tmp/test";
passthru($test);
[php]
popen函数
[php]
$test = "ls /tmp/test";
$fp = popen($tes...