hw can i execute c++ file using php ??.............

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
koolsunny
Forum Newbie
Posts: 5
Joined: Mon Apr 07, 2008 11:26 am

hw can i execute c++ file using php ??.............

Post by koolsunny »

i am using wamp server in windows.......i used exec and system funtion ...... i used syntax like
<?php
exec('g++ filename.cpp' , $result);
echo $result;
?>
but don't get any result..........wat is problem there ?....... space between g++ and filename is a problem??.......... and wat other solution willbe possible for excute cpp file ??..........
Last edited by koolsunny on Tue Apr 08, 2008 12:59 am, edited 1 time in total.
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Re: hw can i execute c++ file using php ??.............

Post by timvw »

You have to make sure that g++.exe is in the PATH of the user that executes the php script
koolsunny
Forum Newbie
Posts: 5
Joined: Mon Apr 07, 2008 11:26 am

Re: hw can i execute c++ file using php ??.............

Post by koolsunny »

timvw wrote:You have to make sure that g++.exe is in the PATH of the user that executes the php script
ya i used correct path but din't get solution ..........can u give me code hint .??......i am trying this from last 2-3 days but don't succeed.........

i am working on a project like a topcoder arena or spoj........where i need to compile solution that is submitted by user(thats will be a cpp file )....... so i need that type of soltion........
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Re: hw can i execute c++ file using php ??.............

Post by Chris Corbyn »

Your host may not allow command line execution. Is it also possible that your code is failing to compile because it needs to know some lib and include paths?
koolsunny
Forum Newbie
Posts: 5
Joined: Mon Apr 07, 2008 11:26 am

Re: hw can i execute c++ file using php ??.............

Post by koolsunny »

Chris Corbyn wrote:Your host may not allow command line execution. Is it also possible that your code is failing to compile because it needs to know some lib and include paths?
In php code what library needed.??.....i used exec and system funtion ......syntax like this

<?php
exec('g++ filename.cpp' , $result);
echo $result;
?>
i also secify path of file directory ..........but not succeed........ can u give me some code hint ........??
Post Reply