<?php // Plug-in 42: Get Title From URL
// This is an executable example with additional code supplied
// To obtain just the plug-ins please click on the Download link
$page = "http://news.yahoo.com";
$result = PIPHP_GetTitleFromURL($page);
if (!$result) echo "The URL '$page' could not be accessed";
else echo "The title of '$page' is:<br /><br /><i>$result</i>";
function PIPHP_GetTitleFromURL($page)
{
// Plug-in 42: Get Title From URL
//
// This plug-in takes the URL of a web page and returns that
// page's title. If the page cannot be loaded then FALSE is
// returned. The argument required is:
//
// $page: The URL of a page, including the preceding
// http://
$contents = @file_get_contents($page);
if (!$contents) return FALSE;
preg_match("/<title>(.*)<\/title>/i", $contents, $matches);
return $matches[1];
}
?>
插件说明:
插件接受一个Werb页面的URL地址,读取并返回它的标题。他需要以下参数:
$page 字符串,包含需要检查的web页面的URL地址。