使用其他Web站点的数据
<html>
<head>
<title> Stock Quote From NASDAQ </title>
</head>
<body>
<?php
$symbol = 'AMZN';
echo "<h1>Stock qupte for ".$symbol."</h1>";
$url = 'http://finance.yahoo.com/d/quotes.csv'.'?s='.$symbol.'&e=.csv&f=fl1d1t1c1ohgv';
if (!($contents = file_get_contents($url))) {
die('Fail to open '. $url);
}
list($symbol, $quote, $date, $time) = explode(',', $contents);
$date = trim($date, '"');
$time = trim($time, '"');
echo "<p>".$symbol." was last sold at: ".$quote."</p>";
echo "<p>Quote current as of ".$date." at ".$time."</p>";
$baiduURL = "http://baidu.com";
echo "This information retrieved from <br /> ";
echo "<p><a href=\"".$baiduURL."\">".$baiduURL."</a></p>";
?>
</body>
</html>
显示结果:
Stock qupte for AMZN
N/A was last sold at: 822.96
Quote current as of 10/14/2016 at 4:00pm
This information retrieved from
http://baidu.com
查询
<html>
<head>
<title> Site submission results </title>
</head>
<body>
<h1>Site submission results</h1>
<?php
$url = $_REQUEST['url'];
$email = $_REQUEST['email'];
$url_parse = parse_url($url);
$host = $url_parse['host'];
if (!$ip = gethostbyname($host)) {
echo 'Host for URL does not have valid IP.';
exit;
}
echo 'Host is at IP '.$ip.' <br />';
$email = explode('@', $email);
$email_host = $email[1];
if (!dns_get_mx($email_host, $mxhostsarr)) {
echo 'Email address is not at valid host.';
exit;
}
echo 'Email is delivered via: ';
foreach($mxhostsarr as $mx) {
echo $mx.'/';
}
echo "<br>All submitted details are ok.<br>";
echo '<br>Thank you for submitting your site.<br>'.
'It will be visited by one of our staff members soon.';
?>
</body>
</html>
结果: