2014-11-02 163 views
0

我正在C中创建一个简单的网络服务器并尝试执行PHP脚本。我可以通过调用: execl(“/ usr/bin/php”,“/ usr/bin/php”,“-q”,phpFile,(char *)NULL)来执行此操作。在C执行PHP脚本

但是,我无法发送获取参数到这个文件。例如:./index.php?name=test 我该怎么做?

回答

0

难道你只是在PHP文件的末尾追加参数? 我认为应该这样的工作:

char phpFile [128] = "./index.php"; 
    char * args = "name=test"; 
    char * args2 = "city=paris"; 
    strcat(phpFile, "?"); 
    strcat(phpFile, args); 
    strcat(phpFile, "&"); 
    strcat(phpFile, args2); // etc. if you want to add more args. 
+0

我可以做到这一点。但execl不会给出适当的结果 – exterminator 2014-11-02 13:13:31