Transwiki:File get contents();
テンプレート:Sakujo/本体 プログラミング言語PHPの関数である。 この関数は因数1 に指定したファイルパス(urlも可能)の内容を取得し返す関数である。
使用方法の例[編集]
$html=file_get_contents("http://example.org");
この例では変数htmlにhttp://example.orgの内容を代入しています。
他関数との連携の例[編集]
$html=file_get_contents("http://google.com/search?q=".urlencode($_GET["q"]));
echo($html);
この例ではgoogle.comの検索結果をこのページに表示します。
$html=file_get_contents("http://ysm.epizy.com");
echo($html);
この例ではysm.epizy.comの内容をこのページに表示します。
$html=file_get_contents("http://google.com");
file_put_contents("index.html",$html);
この例ではgoogle.comの内容をindex.htmlに保存しています。