1
HTML 일부 쿼리에 대해 아무것도 반환하지위키 백과 API는
<html>
<head>
</head>
<form action="check2.php" method="POST">
Search <input type="text" name="search" />
<input type="submit" name="searchbtn" value="search" />
</form>
</body>
</html>
PHP
<?php
$string = $_POST['search'];
$convert = rawurlencode($string);
$url = 'http://en.wikipedia.org/w/api.php?action=query&prop=revisions&rvprop=content&format=xml&redirects&titles='.$convert;
if($_POST['search'] != '' || $_POST['search'] != null) {
$ch = curl_init($url);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
$c = curl_exec($ch);
echo $c;
} else {
}
?>
그것은 내가 (예) "뉴욕"를 검색하면 XML을 반환하지만 내가 "를 검색하면 아무 것도 반환하지 않습니다 싱가포르 동물원 "
'$의 c'의 내용이 무엇입니까? – Passerby
'$ c'을 보셨습니까? – Soundz
나는'parse_str ($ c, $ txArr);을 제거했다. var_dump ($ txArr);'그리고 $ c를 echo했다. 마지막 두 가지는 테스트 코드입니다. 미안합니다. – user1526570