我的 PHP 测试小程序

3

Comments

最近研究 PHP,为了方便,写了个小小的 PHP 页面用来测试简单的 PHP 代码段,为了看了更方便。虽然可能有更好的工具,不过也胡乱贴出来,呵呵~

首先要先在这个文件的文件夹下建立一个 script_test.php 文件,还要把这个文件设为 0777(这是 Linux 的属性,用 Windows 的不用鸟……Windows 的权限设置过于宽松了……)。

然后是代码:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
<?php
$script = stripslashes($_REQUEST['script']);
if ($script !== false) {
	$ftest = fopen("script_test.php", "wb");
	fwrite($ftest, $script);
	fclose($ftest);
}
?>
<?php if ($_REQUEST['ret'] == 'js') : ?>
<script language="javascript">
parent.document.getElementById('show_test').contentWindow.location.reload();
</script>
<?php else : ?>
<style>textarea { width: 100%; height: 400px; }</style>
<table width="100%">
<tr valign="top"><td width="50%">
<form action="?ret=js" method="POST" target="submit_iframe">
<textarea id="script" name="script">
<?php if ($script !== false) : ?><?= $script ?><?php endif; ?>
</textarea><br />
<input type="submit" value="Test" />
</form></td>
<td width="50%"><?php if ($script !== false) : ?>
<iframe id="show_test" src="script_test.php"
 style="border: 1px black solid; width: 100%; height: 400px;"></iframe>
<?php endif; ?>
</td></tr></table>
<iframe id="submit_iframe" name="submit_iframe" style="display: none;"></iframe>
<?php endif; ?>

其中那些高度对于我的显示器效果是不错的,可以根据自己需要调整……

3 Responses to “我的 PHP 测试小程序”

  1. Awaken Says:
    2008年10月4日 16:49 回复

    貌似你的主机不太稳定唉,打开一个页面,经常出service unavailable

  2. Awaken Says:
    2008年10月4日 16:49 回复

    貌似你的主机不太稳定唉,打开页面经常出现503错误 service unavailable

  3. upsuper Says:
    2008年10月5日 09:24 回复

    这是这两天才有的问题……本来是很稳定的……

Leave a Reply