将数据库结果回显到PHP中的html代码的最佳方法是什么? [英] What is the best way to echo results from the database into html code in PHP?

查看:99
本文介绍了将数据库结果回显到PHP中的html代码的最佳方法是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我在数据库中有这样一个值时(foo)

when I have a value like this in the database ("foo")

如何在不与HTML代码发生任何冲突的情况下对其进行回显

how can I echo it without any conflict with html code

notice

notice

<input type="text" value="<? echo '"foo"'; ?>" />

结果会是这样的

<input type="text" value=""foo"" />

我该如何解决它?

how can I fix it ?

推荐答案

使用 urlencode
htmlspecialchars

<a href="<?php echo urlencode($dburl)?>" title="<?php echo htmlspecialchars($dbvalue)?>">link</a>

这篇关于将数据库结果回显到PHP中的html代码的最佳方法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆