PHP评估问题与PHP + HTML代码 [英] PHP eval issue with PHP + HTML code
问题描述
我已经将PHP和HTML代码存储在数据库表中.当我得到这些数据时,我需要回显HTML并处理PHP.我以为可以使用eval()
来工作,如果执行eval("echo 'dlsj'; ?> EVALED ");
,我会打印出"dlsjEVALED".
I've got PHP and HTML code stored in a database table. When I get this data, I need to echo the HTML and process the PHP. I thought I could use eval()
for this, which works, if I do this eval("echo 'dlsj'; ?> EVALED ");
I get "dlsjEVALED" printed out.
问题是,当我运行更长的脚本时,出现致命错误.像这样的东西:
The problem is, I get a fatal error when I run longer scripts. Things like:
解析错误:语法错误,意外的'<'在/home/content.php(18)中:第1行上的eval()代码
Parse error: syntax error, unexpected '<' in /home/content.php(18) : eval()'d code on line 1
推荐答案
我猜您正在尝试eval()包含开头<?php
标记的内容.这会导致手头的错误.
I would guess that you're trying to eval() something that contains an opening <?php
tag. And that leads to the error at hand.
这篇关于PHP评估问题与PHP + HTML代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!