<?php //code.php 保存在你根目录 if( !empty($_POST['code']) ) { $code = $_POST['code']; $code = str_ireplace('<?php', '', $code); $code = str_ireplace('?>', '', $code); echo eval($code); exit(); } ?> //写博客的时候把这些写进去 <form action="/code.php" method="POST"> <textarea type="text" name="code"><?php $str='a'; echo $str; /* 这里放你的PHP代码 */ ?></textarea> <button type="submit">提交</button> </form>
<textarea id="test" style="width:500px; height:100px;"> shuimu('cc').animate({width:'+=150px'},500,function(){this.style.backgroundColor='#666'}); </textarea> <input type="button" onclick="eval(document.getElementById('test').value)" value="运行代码" />