我的 db 列中有这种值,
法官-Fürstová Mila "Ut enim ad minim veniam"
我PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8"
用来处理我所有的特殊字符,
class database_pdo
{
# database handler
protected $connection = null;
# make a connection
public function __construct($dsn,$username,$password)
{
try
{
$this->connection = new PDO($dsn, $username, $password, array(PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8"));
$this->connection->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
}
catch (PDOException $e)
{
# call the get_error function
$this->get_error($e);
}
}
...
...
...
}
当我尝试在输入字段中打印该值时,
<input name="title" type="text" value="<?php echo $page->title;?>"/>
我的输入字段中只有Judge-Fürstová Mila。
如果我htmlentities
用来修复双引号问题,
<input name="title" type="text" value="<?php echo htmlentities($page->title);?>"/>
我在我的输入字段中得到这个,
法官-Fürstová Mila "Ut enim ad minim veniam"
那么,我怎样才能一次解决这个特殊字符和双引号问题呢?