これは私の2つの質問がエラーがあります。 str_replace配列で?
- が速いか等しい、動作するコードの最初のブロックであります
$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;
これは、コードの主要な部分である私にエラー
$illegal = array("&", "<", ">", "\"); $legal = array("&", "<", ">", """); $row['name'] = str_replace($illegal, $legal, $row['name']);
を与えます第二に?
- 2番目のブロックが高速な場合は、どうすれば修正できますか?
ありがとうございます。
と、エラーが何であるかを使用して、実行時の速度をテストすることができますか? ;) –
あなたの投稿で構文の強調表示が壊れているという事実は、あなたに問題の1つを指摘するはずです。 – Mat
'$ illegal = array("& "、" <", "> "、" \ ");' '\"に2番目の引用符がありません。あなたは '' \ ""の代わりに '' "' 'を使うことができます。 – Wiseguy