当前位置:首页> PHP教程> php基础
关键字
文章内容
测试PHP特性的小程序
 
 
修改时间:[2008/06/12 18:46]    阅读次数:[854]    发表者:[起缘]
 
有时候为了测试PHP的特性,要编写一些实验程序,这些程序都不很长,但是数量很多.如果按照一般的编辑-保存-用浏览器打开的方式进行,不是非常方便.所以作者就编写了以下两个小程序来方便测试PHP的特性.
triala.php:
<?php
/*
PHP Trial Tower 0.0.0 By Alexander Fractal Outrules Mar 2001
*/
if (get_magic_quotes_gpc()==1){
foreach ( $HTTP_GET_VARS as $key => $value) $HTTP_POST_VARS[$key]=stripslashes($value);
foreach ( $HTTP_POST_VARS as $key => $value) $HTTP_POST_VARS[$key]=stripslashes($value);
foreach ( $HTTP_COOKIE_VARS as $key => $value) $HTTP_POST_VARS[$key]=stripslashes($value);
}
set_magic_quotes_runtime(0);
?>
<!doctype html public "-//w3c//dtd html 3.2 final//en">
<html>
<head>
<title>PHP Trial Tower A</title>
</head>
<body bgcolor="#ffffff">
<form method='post' action='trialb.php' target='_blank'>
<center>
<textarea rows="20" cols="80" name='RProgram'>
</textarea>
<br><br>
<input type='submit' name='RCommand' value='Run' accesskey='R'>
<input type='reset' value='New' accesskey='N'>
</center>
</form>
</body>
</html>
trialb.php:
<?php
/*
PHP Trial Tower 0.0.0 By Alexander Fractal Outrules Mar 2001
*/
if (get_magic_quotes_gpc()==1){
foreach ( $HTTP_GET_VARS as $key => $value) $HTTP_POST_VARS[$key]=stripslashes($value);
foreach ( $HTTP_POST_VARS as $key => $value) $HTTP_POST_VARS[$key]=stripslashes($value);
foreach ( $HTTP_COOKIE_VARS as $key => $value) $HTTP_POST_VARS[$key]=stripslashes($value);
}
set_magic_quotes_runtime(0);
$output='';
?>
<!doctype html public "-//w3c//dtd html 3.2 final//en">
<html>
<head>
<title>PHP Trial Tower B</title>
</head>
<body bgcolor="#ffffff">
<form method='post' action='#output'>
<center>
<textarea rows="20" cols="80" readonly='true'>
<?php
if(isset($HTTP_POST_VARS['RProgram'])){
eval($HTTP_POST_VARS['RProgram']);
}
echo $output;
?>
</textarea>
</center>
</form>
</body>
</html>
使用时将这两个文件保存在同一个目录/文件夹下,用浏览器打开triala.php,在表单中添入数据提交即可看到结果.
摘自:冰城-PHP的世界
作者:outrules
phpfans.net收集整理