【问题标题】:Execute Php script in C在 C 中执行 PHP 脚本
【发布时间】:2015-09-27 22:09:24
【问题描述】:

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

但是我在将获取参数发送到此文件时遇到问题。例如:./index.php?name=test 我该怎么做?

【问题讨论】:

    标签: c exec


    【解决方案1】:

    你不能在 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.
    

    【讨论】:

    • 我能做到。但是 execl 没有给出适当的结果
    猜你喜欢
    • 2014-12-07
    • 1970-01-01
    • 2014-07-20
    • 2018-02-20
    • 2012-10-09
    • 2011-07-10
    • 2011-12-06
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多