从php脚本执行共享库文件

从php脚本执行共享库文件,php,c++,exec,php-extension,Php,C++,Exec,Php Extension,我创建了共享库client.so。当我执行它时,main()函数get executed从用户那里读取字符串并调用函数ch=foo(缓冲区) Main.cpp位于此处: #include<stdio.h> #include "foo.h" int main() { char buffer[1024]; char *ch; printf("Client : \n"); printf("Enter sent

我创建了共享库client.so。当我执行它时,main()函数get executed从用户那里读取字符串并调用函数
ch=foo(缓冲区)

Main.cpp位于此处:

#include<stdio.h>
#include "foo.h"

    int main()
    {
        char buffer[1024];
        char *ch;
        printf("Client : \n");
        printf("Enter sentence to send to the server (press enter)\n");
        fgets(buffer, 1024, stdin);
        ch=foo(buffer);

        return 0;
    }

有谁能给我一些如何实现这一目标的建议吗

设置权限后,按以下方式执行将解决问题:

$a=exec('/home/technoworld/Videos/LinSocket/client "critic good"'); 
不需要给
/client
,就像我犯了错误一样


客户机是我想要执行的可执行文件,“critic good”是要传递的参数

我会以一种从命令中获取句子的方式重写C程序line@hek2mgl:这是一个很好的选择,但在那之后?在那之后,像这样称呼它:
exec('path/to/yourprog“yourstence”)!!不要错过使用escapeshellarg($句子)before@hek2mgl当前位置我做了这些更改,但没有改进。我的代码:$s=“你好”;escapeshellarg($s)$a=exec(“/home/technoworld/Videos/LinSocket”。/client$s”);客户端是我要执行的共享库文件@hek2mgl:很好的尝试!但同样的错误
exec()
将仅返回命令的最后一行输出。您应该使用
shell\u exec()
$a=exec('/home/technoworld/Videos/LinSocket/client "critic good"');