PHP简单的HTML DOM解析器“字符问题

  1. I got my data from database as like zkjxhvzkjxcvhnzxv"""!^!^!
  2. used dd() for double check if i can get the data from database (i can)
  3. The problem is output i can see is as following in my html: zkjxhvzkjxcvhnzxv
  4. After the character " i can't implement the value into my html element, including "

Here are my codes :

$value = "zkjxhvzkjxcvhnzxv"""!^!^!";
$html = new simple_html_dom();
$html->load('<input type="text" value="'.$value.'">');
echo $html;

A second way to do it but nothing has changed :

$value = "zkjxhvzkjxcvhnzxv"""!^!^!";
$html = new simple_html_dom();
$html->load('<input type="text" id='myID'>');
$input = $html->getElementById('myID');
$input->setAttribute("value", $value);
echo $html;

Thanks in advance.

If i escape the characters, i lose them. But you can use addslashes() method for removing them.

Here's the answer for my situation :

$value = "zkjxhvzkjxcvhnzxv"""!^!^!";
$html = new simple_html_dom();
$html->load('<input type="text" value='.$value.'>');
echo $html;

Change is :

value='.$value.' instead of value="'.$value.'";

Hope this helps anyone.