#native_company# #native_desc#
#native_cta#

PHP Tester

By Eric
on October 24, 2005

Version: 1.2

Type: Full Script

Category: Other

License: GNU General Public License

Description: Lets you test php code from a browser.

<form action=<?php echo $_SERVER['PHP_SELF']; ?> method="post">
PHP Tester 3 (please dont include <? or ?>)
<br>
<br>
<textarea name="test_script" rows="15" cols="75"></textarea>
<br>
<input type="submit" name="submit" value="Test Script">
</form>

<?php

/*
You will need to create a file called script.inc
Upload to your server. CHMOD to 0666 or 0777, whichever works
for you, so that this script can write to it. Change $path to
where you uploaded script.inc, for example:
Say you uploaded to http://www.yourdomain.com/somefolder/script.inc
The path would be: http://www.yourdomain.com/somefolder/
*/

if(!empty($_POST['test_script']))
{
  $script_to_test = $_POST['test_script'];
  $path = "http://www.yourdomain.com/somefolder/";

  if($script_to_test)
  {
    $file = "script.inc";
    if(file_exists($file))
    {
      $fp = fopen("$file", "w");
      fwrite($fp, "<?phpn");
      fwrite($fp, $script_to_test);
      fwrite($fp, "?>n");
      fclose($fp);
      include($path."script.inc");
      exit();
    }
  }
}

?>