這給了我錯誤有錯誤;在str_replace數組?
$illegal = array("&", "<", ">", "\");
$legal = array("&", "<", ">", """);
$row['name'] = str_replace($illegal, $legal, $row['name']);
這是代碼的主要部分
$xml_output = "<?xml version=\"1.0\"?>\n";
$xml_output .= "<products>\n";
for($x = 0 ; $x < mysql_num_rows($resultID) ; $x++){
$row = mysql_fetch_assoc($resultID);
$xml_output .= "\t<product>\n";
$xml_output .= "\t\t<id>" . $row['id'] . "</id>\n";
// Escaping illegal characters
$illegal = array("&", "<", ">", "\");
$legal = array("&", "<", ">", """);
$row['name'] = str_replace($illegal, $legal, $row['name']);
$xml_output .= "\t\t<name>" . $row['name'] . "</name>\n";
$xml_output .= "\t</product>\n";
}
$xml_output .= "</products>";
echo $xml_output;
我的2個問題是
- 是這樣的作品,快於或等於一個代碼塊到第二個?
- 如果第二塊更快,我該如何解決?
謝謝。
,哪些錯誤是測試運行速度? ;) –
語法突出顯示在您的帖子上的事實應該指出您的其中一個問題。 – Mat
'$ illegal = array(「&」,「<", ">」,「\」);'在'「\」'處丟失第二個引號。你可以只用''''而不是'「\」「'。 – Wiseguy