各位大大,急问一个问题比如我现在有个文本输入框(textarea),我想在里面输入一段php代码,就比如最简单的 <?php echo 'hello world';?>,通过递交表单后无论是存入数据库也好,还是用get的方式直接得到也行,现在我想要的就是能在页面上把这些代码显示出来.就比如我上面写的那段,那么我想显示的就是 hello world可是现在什么都不能显示,用火狐的查看页面源代码里能看到<?php echo 'hello world';?>,且是斜体的浅粉红色,不知道什么意思.谢谢各位了!
你这么显示出来的其实是经过HemlEncode编码的“<?php echo 'hello world';?>”
<?
$a="1";
eval("\$b=\$a+1;");
echo $b;
?>
执行结果输出2
<?php
$content = preg_replace('/<\?php|\?>/','',stripslashes($_POST['content']));
if(!is_null($content)) {
eval ($content);
exit(0);
}
?>
<form method="post">
<textarea name="content"></textarea>
<input type="submit"/>
</form>