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.
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.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With