“URL file- access is disabled in the server configuration”というメッセージが表示された場合の対処法

■php.iniの設定が変更可能な場合

PHP コード スニペットを使用していて、ウェブページに “URL file-access is disabled in the server configuration” (URL ファイル アクセスはサーバーの設定で無効になっています) エラー メッセージが表示される場合は、ウェブマスターまたはホスティング プロバイダに連絡して、PHP サーバーの設定内の allow_url_fopen と allow_url_include を有効にしてください。

参考サイト:https://www.google.com/adsense/support/bin/answer.py?hl=jp&answer=70494

■phpファイル内で解決する場合

<? php

function get_content($url)
{
$ch = curl_init();

curl_setopt ($ch, CURLOPT_URL, $url);
curl_setopt ($ch, CURLOPT_HEADER, 0);

ob_start();

curl_exec ($ch);
curl_close ($ch);
$string = ob_get_contents();

ob_end_clean();

return $string;
}

#usage:
$content = get_content (“http://www.php.net”);
var_dump ($content);
?>

参考サイト:http://jp.php.net/manual/ja/function.fopen.php

投稿日:
カテゴリー: 過去Blog タグ:

コメントする

メールアドレスが公開されることはありません。

CAPTCHA