PHP在線調試執(zhí)行的實現(xiàn)方法(附demo源碼)

字號:


    本文實例講述了PHP在線執(zhí)行的實現(xiàn)方法。分享給大家供大家參考,具體如下:
    運行效果截圖如下:
    名單
    run.php文件如下:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>調試php代碼</title>
    </head>
    <style>
     iframe{ min-width:600px;}
     textarea{ max-height:600px}
     table{ margin:0 auto;}
    </style>
    <body>
    <table width="100px">
    <tr>
    <th>PHP 代碼調試</th>
    <th></th>
    <th></th>
    </tr>
    <tr>
    <form action="./run2.php" target="run_iframe" method="post">
    <td valign="top">
    <textarea name="php_code" cols="50" rows="43"><?php
    echo file_get_contents('./run3.php');
    ?></textarea>
    </td>
    <td valign="middle"><button type="submit">執(zhí)行</button></td>
    </form>
    <td valign="top"><iframe id="run_iframe" name="run_iframe" src="./run3.php" height="600px"></iframe></td>
    </tr>
    </table>
    </body>
    </html>
    run2.php文件如下:
    <?php
     $code = stripslashes($_POST['php_code']);
     if(!strstr($code,'<?php'))
      $code = '<?php'.PHP_EOL.$code ;
     file_put_contents('run3.php',$code);
     header("Location:./run3.php");
    完整實例代碼點擊此處本站下載。
    希望本文所述對大家PHP程序設計有所幫助。