3

I'm working on a project and I want to include an HTML script which will hosted on Pastebin.

Something like:

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

I tried

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

But negative.

Aaron Alfonso
  • 516
  • 1
  • 8
  • 27

3 Answers3

3

First you need to enable setting php.ini file as:-

allow_url_include=On

Then there are couple of possible ways to achieve it:

Method 1:

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

Method 2:

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

DO this only if you trust remote source file which you are trying to include.

DocRattie
  • 1,392
  • 2
  • 13
  • 27
Anik
  • 198
  • 2
  • 11
1

Try cURL:

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

Basic example:

$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);

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

RaV
  • 1,029
  • 1
  • 9
  • 25
0

You can do with file_get_contents:

$data = file_get_contents('http://pastebin.com/raw/JyEcHhy2');
Ivan
  • 2,463
  • 1
  • 20
  • 28