PHP:双引号不显示在输入值中,但以正常回显显示 [英] PHP: double quotes don't show in input value, but are shown in normal echo

查看:149
本文介绍了PHP:双引号不显示在输入值中,但以正常回显显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在数据库中有一些字符串,例如 SNEAKERS SUPER STAR GOLDEN GOOSE 。这些是某些产品的标题。当我在< p> 内正常输出时,它会显示引号,但是当我在输入值内回显它时,< input type = text value =<?= $ product-&title; title?> 字符串在第一个双引号之前被截断,因此该值变为 SNEAKERS

I have some strings in the database like SNEAKERS "SUPER STAR" GOLDEN GOOSE. These are the titles for some products. When I output it normally inside a <p> it shows the quotes, but when I echo it inside an input value, <input type="text" value="<?= $product->title ?"> the string gets truncated before the first double quote, so the value becomes just SNEAKERS.

有没有一种方法可以在输入值内输出双引号?

Is there a way I can output the double quotes inside the value of an input ?

编辑:
结束标记是一个错字,在代码中它是关闭的。

The closing tag was a typo, in the code it is closed.

推荐答案

使用 htmlspecialchars 像这样:

htmlspecialchars($product->title);

ie

<input type="text" value="<?= htmlspecialchars($product->title) ?>">

这篇关于PHP:双引号不显示在输入值中,但以正常回显显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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