有时只想测试某个方法的使用方法,可以使用一个页面即时测试.
快速直观
代码------------------
<?php
header('content-type: text/html;charset=GB2312');
$php = empty($_POST['php']) ? 'echo "输入php代码运行快速测试";' : $_POST['php'];
?>
<form method="POST" action="">
<textarea name="php" style="padding:20px;border:1px solid black;width:90%;height:200px;overflow:auto;" wrap="off">
<?php echo $php;?>
</textarea><br/>
<input type="submit" value="运行" />
</form>
<?php
function userErrorHandler() {
$e = func_get_args();
echo '<pre style="color:red;"><br/>----------运行出错---------:<br/>'.print_r($e, 1).'<br/>----------运行出错---------<br/></pre>';
}
set_error_handler("userErrorHandler");
set_exception_handler("userErrorHandler");
function shutdown() {
$a=error_get_last();
if($a != null) echo '<pre style="color:red;"><br/>++++++低级错误+++++<br/>'.print_r($a, 1).'<br/>++++++低级错误+++++<br/></pre>';
}
register_shutdown_function('shutdown');
!empty($_POST['php']) and eval($php.';');
测试效果