PHP在线调试执行的实现方法(附demo源码)

yipeiwu_com6年前PHP代码库

本文实例讲述了PHP在线执行的实现方法。分享给大家供大家参考,具体如下:

运行效果截图如下:

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 border="0" width="100px">
<tr>
<th>PHP 代码调试</th>
<th></th>
<th></th>
</tr>
<tr>
<form action="./run2.php" target="run_iframe" method="post">
<td valign="top" align="center">
<textarea name="php_code" cols="50" rows="43"><?php
echo file_get_contents('./run3.php');
?></textarea>
</td>
<td valign="middle"><button type="submit" style=" width:60px;">执行</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相关内容感兴趣的读者可查看本站专题:《php正则表达式用法总结》、《PHP+ajax技巧与应用小结》、《PHP运算与运算符用法总结》、《PHP网络编程技巧总结》、《PHP基本语法入门教程》、《php操作office文档技巧总结(包括word,excel,access,ppt)》、《php日期与时间用法总结》、《php面向对象程序设计入门教程》、《php字符串(string)用法总结》、《php+mysql数据库操作入门教程》及《php常见数据库操作技巧汇总

希望本文所述对大家PHP程序设计有所帮助。

相关文章

IIS安装Apache伪静态插件的具体操作图文

IIS安装Apache伪静态插件的具体操作图文

Apache和IIS分别有自己的伪静态操作方法,那在Servers2003_IIS需要给PHP程序使用伪静态呢?安装rewrite插件包。一、下载rewrite插件包,一般里面必须有ht...

php基础知识:类与对象(5) static

Declaring class members or methods as static makes th...

PHP实现多图片上传类实例

本文所述为一个实用的PHP多图片文件上传类,其支持gif、jpg、jpeg、pjpeg、png格式的多图片上传功能,类中还可限制图片类型、上传图片的大小、设置上传目录、一些提交判断等功能...

PHP 数据结构 算法 三元组 Triplet

复制代码 代码如下: <?php /** * 三元组 Triplet * */ class Triplet { private $_data = null; // 初始化三元组 p...

php中取得URL的根域名的代码

复制代码 代码如下: <?php /** * 取得根域名 * * @author lonely * @create 2011-3-11 * @version 0.1 * @last...