Get file content via PHP cURL [closed]

I have an website. Let's call it http://www.domain.com. Now, on this domain.com I want to display the file contents of http://www.adserversite.com/ads.php. How can I do that with cURL or another method? I don't want to use iframe.

Thanks


Solution 1:

You can use file_get_contents as Petr says, but you need to activate allow_url_fopen in your php.ini and perhaps your hosting do not allow you to change this.

If you prefer to use CURL instead of file_get_contents, try this code:

<?php
$url = 'http://www.adserversite.com/ads.php';
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HEADER, false);
$data = curl_exec($curl);
curl_close($curl);

Solution 2:

echo file_get_contents('http://www.adserversite.com/ads.php');

Who needs curl for this simple task?