Re: curl equivalent in PHP

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hmm..I am a php newbie ( just started learning it )...

what my need is to display website from my server always for a
non-registered domain.This is the code I use now to display the website

<?php
$opts = array(
  'http'=>array(
    'method'=>"GET",
    'header'=>"Accept-language: en\r\n" .
              "Cookie: foo=bar\r\n"
  )
);

$context = stream_context_create($opts);

$fp = fopen('http://www.blahblah.com', 'r', false, $context);
fpassthru($fp);
fclose($fp);
?>

Of course blahblah.com isn't registered yet. This will load the index page
of blahblah.com fine ( since I use hosts file to resolve blahblah.com on
the server ). But if we click on any link, it will give "server not found"
error since my "local machine" is trying to resolve blahblah.com this time.
I need to avoid it and want to load my domain "always" from the server when
I click any link on the webpage, etc .

How can I modify the above code to make it work! If possible, I request
somebody to tell me the exact code that I need to change in the above
script - since most of the php part is still greek to me :)

Thank you,



On Fri, Mar 2, 2012 at 10:09 PM, Micky Hulse <rgmicky@xxxxxxxxx> wrote:

> Hello,
>
> On Fri, Mar 2, 2012 at 8:07 AM, Jim Lucas <lists@xxxxxxxxx> wrote:
> >> But on some of my servers, curl isn't enabled! Is there any equivalent
> >> code
> >> to  achieve the same?
>
> I've used a combination of output buffering [1], readfile() [2] and
> caching (specific to the framework I was using).
>
> Simply, you could resort to:
>
> <?php readfile('http://www.google.com'); ?>
>
> Ofc, the links would need to be absolute in order for the assets to load.
>
> Good luck!
>
> Cheers,
> Micky
>
>    [1] php.net/ob-start
>    [2] php.net/readfile
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


-- 
Regards....

Nibin.

http://TechsWare.in

[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux