我知道现在很多公司开发产品都采用java来做后台,用php来做前台,我想问的是如果用C++来做后台的话,他们之间的通信方式是怎样的,用软件来处理数据的话却是比脚本快啊,php怎样和软件通信?又比如网页通过传一参数如何调用软件么个函数呢?socket?soap?还是什么听很多人说可以但从未接触过类似案例,望高人指点一二

解决方案 »

  1.   


    PHP直接调用COM类似的方式在WEB中有一定的应用,基本上消息队列等系统服务都是用C++来实现的,然后以WEB服务或者类似的方式暴露给PHP调用
      

  2.   

    网页通过传一参数如何调用软件么个函数呢?建议参考: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);
    ?> 
      

  3.   

    这西基本都知道,要的不是这种我想假设我说的假设我用将现有后台改用vc,而前台用php,通过游览器传参通知软件启动一线程比如和mysql交互做一数据插如操作,vc到是很好和php交互可以自己软件里获取带参的程序,但php怎么和软件通信呢而且不希望用com这样每次都的载入内存,我的想法是二十四小时开始软件,处于监听状态,当apache有请求过来了就放入消息队列心中处理,就是不知他们之间用何种方式通信比较好?之前和java通信的时候,是通过soap接口进行数据的调用,但我想vc应该有更合理的通信方式吧?当然这只是我今晚突然的想法而已,好奇还望各位大大指点一二!
      

  4.   

    这西基本都知道,要的不是这种我想假设我说的假设我用将现有后台改用vc,而前台用php,通过游览器传参通知软件启动一线程比如和mysql交互做一数据插如操作,vc到是很好和php交互可以自己软件里获取带参的程序,但php怎么和软件通信呢而且不希望用com这样每次都的载入内存,我的想法是二十四小时开始软件,处于监听状态,当apache有请求过来了就放入消息队列心中处理,就是不知他们之间用何种方式通信比较好?之前和java通信的时候,是通过soap接口进行数据的调用,但我想vc应该有更合理的通信方式吧?当然这只是我今晚突然的想法而已,好奇还望各位大大指点一二!
      

  5.   

    其实php做后台一点问题都没有。很多百万级的系统都是这样。