简体   繁体   English

html代码显示在php字符串中

[英]html code showing up in php string

I am using var_dump to output a string but the length is different then what is showing so I printed out each character and found there are the hidden html codes #40; 我正在使用var_dump输出字符串,但是长度与显示的长度不同,因此我打印出每个字符并发现有隐藏的html代码#40; and #41; 和#41; in the string attributing to the length. 在归因于长度的字符串中。 These are causing problems in an sql statement so I am trying to remove them, but htmlspecialchars_decode, and urldecode do not remove the characters. 这些在sql语句中引起问题,因此我尝试删除它们,但是htmlspecialchars_decode和urldecode不会删除字符。 How can I get ride of these codes? 如何获得这些代码? The value is coming from a database is utf-8 (CHARSET=utf8 COLLATE=utf8_bin) and does not have any html codes stored in it (stored as "Civic (sedan)" in table). 来自数据库的值是utf-8(CHARSET = utf8 COLLATE = utf8_bin),并且其中没有存储任何html代码(在表中存储为“ Civic(轿车)”)。

//this is the output of the string
Civic (#40;sedan)#41;
echo var_dump($data['model']).'<br>';

//output
string(21) "Civic (sedan)" 

echo var_dump(strip_tags($data['model'])).'<br>';

//output
string(21) "Civic (sedan)" 

echo var_dump(htmlspecialchars_decode($data['model'])).'<br>';

//output
string(21) "Civic (sedan)" 

echo var_dump(urldecode($data['model'])).'<br>';

//output
string(21) "Civic (sedan)" 

html_entity_decode()是您所追求的,我认为...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM