我有一个MySQL数据库,其中一个字段中包含代码。
test test test <?php $_GET['location']; ?> test test
我正在访问显示文件test.php?location=abc,并以以下方式从数据库中显示该记录。
This is my <?php echo $row_display_content['location']; ?>
我得到的唯一结果是:
This is my
我不知道如何让它工作,所以需要从数据库中显示动态值来填充文本。
我有一个MySQL数据库,其中一个字段中包含代码。
test test test <?php $_GET['location']; ?> test test
This is my <?php echo $row_display_content['location']; ?>
This is my
我不知道如何让它工作,所以需要从数据库中显示动态值来填充文本。
使用 eval
函数。顺便说一下,这是解决任何问题的可怕方法。
http://php.net/manual/en/function.eval.php
编辑:
$code = 'test test test <?php $_GET[\'location\']; ?> test test';
eval('?>'. $code);
尝试
echo "This is my ". eval('?>' . $row_display_content[\'location\'] . '<?php ');
看一下eval,在数据库条目中不应包含php标签。此外,您应该问自己是否真的想将其存储在数据库中。