I'm very new to PHP. Currently,I'm facing one issue to escape \ and store in mysql DB.
eg., If the string is like $str = \\aaaa\bbb\\\cccc$$
, I would like to save that string in DB . However, I don't know how to escape those backslashes. Please help me settle it.
1 回答
2
您最好的选择是使用准备好的语句(例如通过PDO):
$dbh = new PDO(…);
$sth = $dbh->prepare('INSERT INTO `yourtable` ( `column` ) VALUES ( :string )');
$sth->execute(array(':string' => '\\aaaa\bbb\\\cccc$$'));
于 2011-09-28T10:09:26.667 回答