fedora10

executing php script from C program and store the results in to a variable

為{幸葍}努か 提交于 2019-11-29 23:38:28
问题 I would like to execute a PHP script from a C program and store the returning content in to a C variable. I tried like following but it doesn't work: C: printf("calling php function\n"); execl("/usr/bin/php -q", "/var/www/html/phpinfo.php", NULL); printf("End php function\n"); PHP: <?php echo "hello"; ?> Environment: PHP 5.2.6 Apache 2.0 Fedora Core 10 Also suggest any other better way to do this. 回答1: Short answer here is to use system() or popen() rather than execl() . Seeing as Jason has