2016-05-13 12 views
3

私はプロジェクトに取り組んでいます。私はPastebinでホストされるHTMLスクリプトを含めたいと思います。以下のようなリモートHTMLファイルを含む

何か:

include 'http://pastebin.com/raw/testiungshdhd';  

は私が

fgets(fopen('http://pastebin.com/raw/asdasddaqwe', 'r')); 

しかし、負のを試してみました。

+3

http://stackoverflow.com/questions/1158348/including-a-remote-file-in-php – Suyog

答えて

1

てみカール:

http://php.net/manual/en/book.curl.php

Basicの例:

$ch = curl_init("http://www.example.com/"); 
$fp = fopen("example_homepage.txt", "w"); 

curl_setopt($ch, CURLOPT_FILE, $fp); 
curl_setopt($ch, CURLOPT_HEADER, 0); 

curl_exec($ch); 
curl_close($ch); 
fclose($fp); 

参考:http://php.net/manual/en/curl.examples-basic.php

+0

他にも 'include '';'と同じような単純な方法はありません。 –

+0

そのように含まれています。 curl_include()のような関数を文字列paramで書くことができ、それはincludeと同じように動作します。 – RaV

0

あなたがfile_get_contentsで行うことができます。

$data = file_get_contents('http://pastebin.com/raw/JyEcHhy2'); 
3

まず、あなたはとしてphp.iniファイルを設定し有効にする必要があります: - :

方法1:

<?php 
    include("http://pastebin.com/raw/asdasddaqwe"); 
?> 

方法2

allow_url_include=On 

が、それを達成することが可能な方法がいくつかあります:

これは、含まれようとしているリモートソースファイル。

関連する問題