Review your favorite Linux distribution.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 06-03-2007, 03:49 PM   #1
Registered: Aug 2005
Posts: 75

Rep: Reputation: 15
executing C++ code from within PHP code

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,
Old 06-03-2007, 04:13 PM   #2
Registered: May 2007
Distribution: Debian
Posts: 103

Rep: Reputation: 15
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:

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



Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Executing command line through Code socialjazz Programming 2 10-02-2006 03:09 PM
merge ASP code with PHP code.. possible ?? ALInux Programming 7 12-30-2005 08:40 AM
User Preferences: Use HTML code instead of vB code? (vB code is overrated) stefanlasiewski LQ Suggestions & Feedback 5 07-26-2005 01:37 AM
Problem in executing code in gcc gcc_learner Programming 3 03-26-2005 03:28 AM
executing shell code from stack djidji Fedora 3 03-07-2005 05:19 AM

All times are GMT -5. The time now is 02:15 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration