Created
February 20, 2015 22:08
-
-
Save benwills/cf753c974b1cf609b03a to your computer and use it in GitHub Desktop.
Execute PHP from C. From http://stackoverflow.com/questions/2179465/execute-and-output-php-on-a-c-based-web-server-stuck
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
char buf[BUFSIZ]; | |
FILE *fp; | |
if ((fp= popen("/bin/php -f /webserver/pages/test.php", "r")) != NULL) | |
{ | |
/* Read from the PHP command output */ | |
while (fgets(buf, BUFSIZ, fp) != NULL) | |
{ | |
/* Process the output from PHP as desired */ | |
... | |
} | |
(void) pclose(ptr); | |
} | |
fclose(fp); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment