LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   executing C++ code from within PHP code (https://www.linuxquestions.org/questions/programming-9/executing-c-code-from-within-php-code-558879/)

vineet7kumar 06-03-2007 03:49 PM

executing C++ code from within PHP code
 
hi,
i have written a program in C++. I want to execute it from within my PHP code . how can i do it?

thanx and regards,
viny

digitalnerds 06-03-2007 04:13 PM

Hey there

Assuming c++ program is compiled already you will have to use the php system() function to execude system commands. You can also use php's exec() function as well. For both of them php's installation must allow you this. As an example. You can take as example a single script to execute xmms player on linux from php using exec() or system() variables:

Code:

<?php
echo ' Executing XMMS ';
// note you could use system too!
//echo system( '/usr/bin/xmms --play icould.wav', $retval );
exec ('/usr/bin/xmms --play icould.wav');
?>

system() variable doesnt return by default the executed command output so that's the $retval purpose.

Hope it helps

Regards
Andy


All times are GMT -5. The time now is 07:39 PM.