自己搭建本地 php 在线执行环境

php 调试工具

主要是三个文件

新建1, run.php

可根据自己屏幕大小调适合自己的css样式

 1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 2 <html xmlns="http://www.w3.org/1999/xhtml">
 3 
 4 <head>
 5     <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
 6     <title>调试php代码</title>
 7 </head>
 8 <style>
 9     iframe {
10         min-width: 700px;
11     }
12 
13     textarea {
14         max-height: 700px
15     }
16 
17     table {
18         margin: 0 auto;
19     }
20 </style>
21 
22 <body>
23     <table border="0" width="100px">
24         <tr>
25             <th>PHP 代码调试</th>
26             <th></th>
27             <th></th>
28         </tr>
29         <tr>
30             <form action="./run2.php" target="run_iframe" method="post">
31                 <td valign="top" align="center">
32                     <textarea name="php_code" cols="100" rows="43">
33                         <?php
34                             echo file_get_contents('./run3.php');
35                         ?>
36                     </textarea>
37                 </td>
38                 <td valign="middle"><button type="submit" style=" 60px;">执行</button></td>
39             </form>
40             <td valign="top"><iframe id="run_iframe" name="run_iframe" src="./run3.php" height="650px"></iframe></td>
41         </tr>
42     </table>
43 </body>
44 
45 </html>
新建2,run2.php
1 <?php
2 $code = stripslashes($_POST['php_code']);
3 if (!strstr($code, '<?php'))
4     $code = '<?php' . PHP_EOL . $code;
5 file_put_contents('run3.php', $code);
6 header("Location:./run3.php");
 
 
新建3,run3.php
 
1 <?php
2 
3 // echo phpinfo();  //空文件即可,执行后会自动写入
 

php 环境 下
浏览器到服务目录下运行run.php即可
 
效果图如下
 

 
 
原文地址:https://www.cnblogs.com/haoyuekey/p/12800857.html