我試圖做這樣的somwthing(其中$ DOC是一個DOMDocument)PHP的setAttribute更換及與&
$link_found = $doc->getElementsByTagName('a');
foreach ($link_found as $idx => $link) {
$link->setAttribute('href', "/test.php?t=1&q=2") ;
}
所有的工作,但在href現在我
"/test.php?t=1&q=2"
我需要的文字&
,在&
沒有編碼,我需要
"/test.php?t=1&q=2"
像一個普通的查詢字符串
這會是無效的HTML。您無法使用DOM功能生成無效的HTML。這是一個功能,而不是一個錯誤。 – 2013-03-18 16:56:10
?這是一個正常的查詢字符串... 像谷歌: http://www.google.it/#hl=it&sclient=psy-ab&q=example – realtebo 2013-03-18 16:56:51
也許嘗試使用html_entity_decode? http://www.php.net/manual/en/function.html-entity-decode.php – 2013-03-18 17:00:35