PHPスクリプト/file_get_contents()

file_get_contents()

ファイルの内容を全て文字列に読み込む

書式

string file_get_contents ( string filename [, bool use_include_path [, resource context [, int offset [, int maxlen]]]] )

ホームページのタイトル<title></title>を抜き出して表示

<?php
$d = file_get_contents("http://ma21.ath.cx/");
$d = @mb_convert_encoding($d, "EUC-JP", constant("TO_ENCODING"));
preg_match("/<title[^>]*>([^<]*)<\/title>/i",$d,$t);
$title = trim($t[1]);
print $title;
?>