网页通过传一参数如何调用软件么个函数呢?建议参考: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; ?> 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'); ?> popen (PHP 4, PHP 5)popen — 打开进程文件指针说明 resource popen ( string $command , string $mode ) 打开一个指向进程的管道,该进程由派生给定的 command 命令执行而产生。 返回一个和 fopen() 所返回的相同的文件指针,只不过它是单向的(只能用于读或写)并且必须用 pclose() 来关闭。此指针可以用于 fgets(),fgetss() 和 fwrite()。 如果出错返回 FALSE。 Note: 如果需要双向支持,使用 proc_open()。 Example #1 popen() 例子<?php $handle = popen("/bin/ls", "r"); ?> Note: 如果未找到要执行的命令,会返回一个合法的资源。这看上去很怪,但有道理。它允许访问 shell 返回的任何错误信息: <?php error_reporting(E_ALL);/* 加入重定向以得到标准错误输出 stderr。 */ $handle = popen('/path/to/spooge 2>&1', 'r'); echo "'$handle'; " . gettype($handle) . "\n"; $read = fread($handle, 2096); echo $read; pclose($handle); ?>
PHP直接调用COM类似的方式在WEB中有一定的应用,基本上消息队列等系统服务都是用C++来实现的,然后以WEB服务或者类似的方式暴露给PHP调用
(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;
?> 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');
?> popen
(PHP 4, PHP 5)popen — 打开进程文件指针说明
resource popen ( string $command , string $mode )
打开一个指向进程的管道,该进程由派生给定的 command 命令执行而产生。 返回一个和 fopen() 所返回的相同的文件指针,只不过它是单向的(只能用于读或写)并且必须用 pclose() 来关闭。此指针可以用于 fgets(),fgetss() 和 fwrite()。 如果出错返回 FALSE。 Note: 如果需要双向支持,使用 proc_open()。 Example #1 popen() 例子<?php
$handle = popen("/bin/ls", "r");
?> Note: 如果未找到要执行的命令,会返回一个合法的资源。这看上去很怪,但有道理。它允许访问 shell 返回的任何错误信息: <?php
error_reporting(E_ALL);/* 加入重定向以得到标准错误输出 stderr。 */
$handle = popen('/path/to/spooge 2>&1', 'r');
echo "'$handle'; " . gettype($handle) . "\n";
$read = fread($handle, 2096);
echo $read;
pclose($handle);
?>