I want to create a c++ compiler on my website using php. How do I do that? Pls help. thank you

Recommended Answers

All 12 Replies

Member Avatar for diafol

Erm. You sure you really want to do that? Not saying it can't be done, but not sure if PHP is the right tool for the job. Giving me a nosebleed just thinking about it. Most compilers I know of use C/C++. That's for a good reason. An oft-cited issue against PHP is using strings for binary arithmetic. Why do you need to do this - or more correctly, why does it need to be in PHP?

jeffersonalomia ,
I hope you know that PHP can execute an external program. That way you can save the original C++ code in a file , and run the C++ compiler with arguments the file.
@see http://php.net/manual/en/function.exec.php

But ... as Diafol wrote , why in earth , do you want to do such thing?

thanks for your response jkon and diafol. i wanted to do this because of my thesis, which is about E-Learning on c++. And I want to make the users have the ability to code on the website that i have developing about E-Learning c++.

May I have your suggestions as an alternative features that i can include on my E-Learning. I will appreciate all your response. Thanks

Member Avatar for diafol

May I have your suggestions as an alternative features that i can include on my E-Learning. I will appreciate all your response. Thanks

I have no idea what this means. Are you struggling for ideas for your thesis? As jkon says, you can use PHP to run executables - a compiler even? So it would, AFAIK do what you want. Are you looking to create "an online C++ compiler"?

is there any online c++ compiler that can be embed on my website?

My thesis is about E-Learning System and somehow I want to use that compiler as a feature on my ELS to make the user apply what they`ve learn on my E Learning System

Im confuse with this note from http://php.net/manual/en/function.exec.php

If a program is started with this function, in order for it to continue running in the background, the output of the program must be redirected to a file or another output stream. Failing to do so will cause PHP to hang until the execution of the program ends.

Do I need to create a c++ file and write the inputted code inside that cpp file?

Member Avatar for diafol

Having you read the php manual on exec() as jkon suggested? I'm not sure what more I could add to that.

You access the compiler (which would be an .exe file) as per the examples and in the link which I included.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.