我已将Word文档导入MySQL数据库[utf8_general_ci]。一列有html代码:
<p class=“hangi”><b>Robert ALGAR</b>, b. 1435.</p>
这些智能引号在互联网浏览器中不起作用。我试图将它们更改为阻止引号的PHP代码无效,即没有检测到引号并将它们更改为阻止引号:
$sql = "UPDATE `lwadb`.`ancestorIndex` SET `descendants`='".$this->convert_smart_quotes($desc)."' WHERE `ancestorIndex`.`surname` ='".$entry."';";
$result = $conn->query($sql);
if($result) {echo "</br>ENTRY UPDATEED";}
else{echo "Error updating record: "; print_r($this->mysqli->error_list);}
}
function convert_smart_quotes($string) {
$search = array(chr(145), chr(146), chr(147), chr(148), chr(151));
$replace = array("'", "'", '"', '"', '-');
return str_replace($search, $replace, $string);
}
答案 0 :(得分:0)
我在这里看不到问题。只需替换这两个引号字符:
<?php
$input = '<p class=“hangi”><b>Robert ALGAR</b>, b. 1435.</p>';
$output = str_replace(['“','”'], '"', $input);
echo $output;