Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > PHP/MySQL > Pro PHP
Password Reminder
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
Pro PHP Advanced PHP coding discussions. Beginning-level questions will be redirected to the Beginning PHP forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Pro PHP section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old January 8th, 2008, 04:21 PM
Registered User
Join Date: Jan 2008
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default PHP to parse C code

I was thinking to senario like this:
I will create a text area where I will allow student to write their C code in that text area.
I wanna create a button called [Compile].
This button will compile my C code in text area.
(Expectation: The compile button will compile my C code and give the output exactly the same as gcc compiler)
Could someone let me know how to start with it.
Reply With Quote
  #2 (permalink)  
Old January 25th, 2008, 06:38 AM
Registered User
Join Date: Jan 2008
Location: Portsmouth, Hampshire, , United Kingdom.
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts

It's possible to use the exec,passthru and system functions to call external programs from a PHP script and return their output. Exec returns the output to an array rather than outputting raw data, so this may be more suitable.

The steps I would take to approach this:
1) Fetch code from textarea and write to a new C source file.
2) Use exec to pass the file to your compiler and return the output.
3) Output the array.

There may be a more elegant means of dealing with external programs but this is the best method that springs to mind.

Reply With Quote

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
PHP Parse error: parse error, unexpected T_STRING geminient PHP How-To 4 August 18th, 2007 02:27 AM
php parse error ajit_kunte BOOK: Professional PHP 5 ISBN: 978-0-7645-7282-1 2 May 2nd, 2005 07:24 AM
MySQL & PHP Parse error Stuart BOOK: Beginning PHP, Apache, MySQL Web Development ISBN: 978-0-7645-5744-6 1 March 17th, 2005 03:44 PM

All times are GMT -4. The time now is 09:02 PM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.