# Thread: QuickPHP

1. ## QuickPHP

QuickPHP allows you to very quickly execute any PHP code in a few seconds, from your desktop.

It means you don't have to make a new file, run it on localhost or upload to a server, continue editing in a seperate editor etc etc - it can all get time consuming and sometimes you just don't want to bother anymore. With QuickPHP, you can just run the program, write the script and click the button for instant results.

Example use:

Clicking "Execute" would execute the code, thus;

Hopefully that'll give you an example as to how this app can be useful.

It was compiled with KrakJoe's glorious phpCompile. Here's the actual script itself. (you'll also need the winbinder library).

(NOT UPDATED, this is old code, scroll down to most recent posts for newest)
PHP Code:
 <?php ob_start(); include("include/winbinder.php");                 // Location of WinBinder library $mainwin = wb_create_window(NULL, AppWindow, "QuickPHP", 600, 493); wb_create_control($mainwin, EditBox, "",   10, 10, 480, 450,     101, WBC_MULTILINE);  wb_create_control($mainwin, PushButton, "Execute", 500, 10, 80, 22, 102); wb_create_control($mainwin, PushButton, "Help/About",  500,35, 80, 22,     103);  wb_set_handler($mainwin, "process_main"); wb_main_loop(); function process_main($window, $id) { switch($id) {      case 102:                       $getboxvalue = wb_get_text( wb_get_control($window, 101 ) );             $getboxvalue = str_replace(array("<?php", "?>"), "",$getboxvalue);                          eval($getboxvalue);$result = ob_get_contents();             ob_clean();             $reswin = wb_create_window(NULL, AppWindow, "Output", 600, 493); wb_create_control($reswin, EditBox, $result, 10, 10, 570, 450, 104, WBC_MULTILINE); wb_set_handler($reswin, "process_results");       wb_main_loop();                       break;           case 103:             wb_message_box($window, "Simply enter the code you want to test quickly and click \"Execute\". \nPlease note this will execute on your actual system so if you use commands like exec(), unlink(), and others it WILL have effect.\n\nThis isn't meant for executing full scripts, just small ones to see if they work or to quickly generate lists etc.", "About QuickPHP"); break; case IDCLOSE: // The constant IDCLOSE is predefined wb_destroy_window($window);       // Destroy the window             break;       } } function process_results($window,$id)  {                switch($id) { case IDCLOSE: // The constant IDCLOSE is predefined wb_destroy_window($window);       // Destroy the window             break;        } } ?> 
And here's it pre-compiled:

(NOT UPDATED, this is old compiled code, scroll down to most recent posts for newest)
http://rapidshare.com/files/119059358/QuickPHP.zip

Note: You will need to leave the compiled script in the same directory as the uncompiled script, due to usage of ob_contents() and eval(). I recommend you put it in a directory somewhere in /Program Files/, and make a shortcut to your desktop or elsewhere of the main file.

If you would like to add anything to the script, please do so in this thread.

There's no license, but be respectful when using the source. Don't claim it's yours .

2. awesome stuff... maybe the recognition thingy? the one that adds color to different stuff in PHP, like variables are green and all that...

3. Ah, syntax

Should be possible.. I'll take a look into it, it might not be very easy though ..

4. well, my only suggestion is to make it recognize web html so that you can use it to test site code too. save the trouble of installing xampp and turning your home comp into a local server. this would be really cool.

5. (OLDER VERSION, this is old code, scroll down to most recent posts for newest)

Done
Entire Code:
PHP Code:
 <?php ob_start(); include("include/winbinder.php");  $mainwin = wb_create_window(NULL, AppWindow, "QuickPHP", 600, 493); wb_create_control($mainwin, EditBox, "",   10, 10, 480, 450,     101, WBC_MULTILINE);  wb_create_control($mainwin, PushButton, "Execute", 500, 10, 80, 22, 102); wb_create_control($mainwin, PushButton, "Help/About",  500,35, 80, 22,     103);  wb_create_control($mainwin, ComboBox, "", 500,60, 80, 90, 105);$a_combo = array("Plain", "HTML"); wb_set_text(wb_get_control($mainwin, 105),$a_combo); wb_set_handler($mainwin, "process_main"); wb_main_loop(); function process_main($window, $id) { switch($id) {      case 102:                       $getboxvalue = wb_get_text( wb_get_control($window, 101 ) );             $getboxvalue = str_replace(array("<?php", "?>"), "",$getboxvalue);                           eval($getboxvalue);$result = ob_get_contents();             ob_clean();                          if(wb_get_text( wb_get_control( $window, 105 ) ) == "Plain") {$reswin = wb_create_window(NULL, AppWindow, "Output", 600, 493);          wb_create_control($reswin, EditBox,$result,   10, 10, 570, 450,     104, WBC_MULTILINE);          wb_set_handler($reswin, "process_results"); wb_main_loop(); } elseif(wb_get_text( wb_get_control($window, 105 ) ) == "HTML") {         $handle = fopen("out.html", 'w+'); fwrite($handle, $result); fclose($handle);         wb_exec("out.html");       }           break;           case 103:             wb_message_box($window, "Simply enter the code you want to test quickly and click \"Execute\". \nPlease note this will execute on your actual system so if you use commands like exec(), unlink(), and others it WILL have effect.\n\nThis isn't meant for executing full scripts, just small ones to see if they work or to quickly generate lists etc.", "About QuickPHP"); break; case IDCLOSE: wb_destroy_window($window);              break;       } } function process_results($window,$id)  {        switch($id) { case IDCLOSE: wb_destroy_window($window);             break;        } } ?> 
(What's changed: ComboBox added with options of Plain or HTML. Plain will be as before, HTML will create the .html file and open it - hopefully in your browser).

Pre-Compiled:
http://rapidshare.com/files/119106111/QuickPHPv0.2.zip

6. That way you can test your stuff on your company's PC without having to install xampp evils!

EDIT: How about releasing this as freeware on the net? Maybe rebrand it as QUIKPHP and register QUIKPHP.COM and start your next amazing website

7. Indeed! It certainly has it's limitations compared to XAMPP though; it's only one page of code for starters and I haven't tried includes. Includes would probably work, but most likely you'd have to include the direct path - eg include("C:\path\to\file.php"); rather than simply include("file.php");

8. I've noticed it doesn't like HTML code unless it's echo'd by php. Should be fixable.

9. Originally Posted by hamster
EDIT: How about releasing this as freeware on the net? Maybe rebrand it as QUIKPHP and register QUIKPHP.COM and start your next amazing website
quoted for attention

10. Don't need to brand it... besides, I can't get it to work without including the source. So I'm just releasing it as open source

Thanks for the idea though.

11. Nice one Col, get Joe to put it on his site as a great example of what can be done

12. That looks pretty great. Good work. I'll give it a whirl later in the day.

13. Originally Posted by Decker
Nice one Col, get Joe to put it on his site as a great example of what can be done
Yep.. he's welcome to! Wouldn't be able without him anyhow!

Thanks Tree

----

Well, I just fixed it up so that it can parse HTML properly now. I present v0.2.1

PHP Code:
 <?php ob_start(); include("include/winbinder.php");  $mainwin = wb_create_window(NULL, AppWindow, "QuickPHP", 600, 493); wb_create_control($mainwin, EditBox, "",   10, 10, 480, 450,     101, WBC_MULTILINE);  wb_create_control($mainwin, PushButton, "Execute", 500, 10, 80, 22, 102); wb_create_control($mainwin, PushButton, "Help/About",  500,35, 80, 22,     103);  wb_create_control($mainwin, ComboBox, "", 500,60, 80, 90, 105);$a_combo = array("Plain", "HTML"); wb_set_text(wb_get_control($mainwin, 105),$a_combo); wb_set_handler($mainwin, "process_main"); wb_main_loop(); function process_main($window, $id) { switch($id) {      case 102:                       $getboxvalue = wb_get_text( wb_get_control($window, 101 ) );             $getboxvalue = str_replace(array("####<?php", "?>####"), "", "####".trim($getboxvalue)."####");                          eval($getboxvalue);$result = ob_get_contents();             ob_clean();                          if(wb_get_text( wb_get_control( $window, 105 ) ) == "Plain") {$reswin = wb_create_window(NULL, AppWindow, "Output", 600, 493);          wb_create_control($reswin, EditBox,$result,   10, 10, 570, 450,     104, WBC_MULTILINE);          wb_set_handler($reswin, "process_results"); wb_main_loop(); } elseif(wb_get_text( wb_get_control($window, 105 ) ) == "HTML") {         $handle = fopen("out.html", 'w+'); fwrite($handle, $result); fclose($handle);         wb_exec("out.html");       }           break;           case 103:             wb_message_box($window, "Simply enter the code you want to test quickly and click \"Execute\". \nPlease note this will execute on your actual system so if you use commands like exec(), unlink(), and others it WILL have effect.\n\nThis isn't meant for executing full scripts, just small ones to see if they work or to quickly generate lists etc.\n\nTo view the output as HTML, choose \"HTML\" from the drop-down.", "About QuickPHP"); break; case IDCLOSE: wb_destroy_window($window);              break;       } } function process_results($window,$id)  {        switch($id) { case IDCLOSE: wb_destroy_window($window);             break;        } } ?> 
http://rapidshare.com/files/11911012...kPHPv0.2.1.zip

Basically.. it always messes up if it starts with <?php. So (previously) I did a simple str_replace() where it remvoed all <? tags. This time, I've fixed it so it'll only remove the very first, and very last tags. Everything in between will work fine!

Again.. report bugs.. suggest features.. even work on it yourself, that's why it's open source .

14. Thats a nice idea Colin. That certainly could help me a lot during certain developments. Rep + Thumbs up.

15. I'm trying desperately to think of something I could try it with now!

What a time to get a mental block

Closed Thread

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts