< > " & '修改自http://quartergeek.com/fix-special-char-replaced-by-syntaxhighlighter
代码增加了单引号的替换,同时增加几个变量提醒用户修改。
自从换上了Crayon Syntax Highlighter,发现原来<>&”’符号被WP替换成了< > " & ‘而Crayon Syntax Highlighter又不能转换,只好转回来,于是写了下面这个脚本,成功地替换回来了。
set_charset("utf8"); $result = $conn->query("SELECT post_content, ID FROM ".$ta); $stmt = $conn->prepare("UPDATE ".$ta." SET post_content = ? WHERE ID = ?"); $search = array("<", ">", """, "&", "'"); $replace = array("<" , ">" , "\"" , "&" ,"'"); while ($row = $result->fetch_array()) { $id = $row['ID']; $post_content = str_replace($search, $replace, $row['post_content']); $stmt->bind_param('si', $post_content, $id); if (!$stmt->execute()) { die("\n[ERROR!]".$id."\n"); } else { echo "[Success]".$id."\n"; } } $result->free(); $conn->close(); ?>