HTML
<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 {
}
?>
如果我搜索(例如)“New York”,它会返回 XML,但如果我搜索“Singapore Zoo”,它什么也不返回