Wrox Programmer Forums
Go Back   Wrox Programmer Forums > PHP/MySQL > Pro PHP
|
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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 8th, 2008, 04:21 PM
Registered User
 
Join Date: Jan 2008
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.
 
Old January 25th, 2008, 06:38 AM
Registered User
 
Join Date: Jan 2008
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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.








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





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