I'm trying to use file_get_contents to retrieve the output a browser would receive from another file on the same domain. I've moved to another server and now it always gets a timeout. Below is a sample of what I'm trying to do.
index.php
<?php
echo file_get_contents('http://'.$_SERVER['SERVER_NAME'].'/sample.php');
?>
sample.php
<?php
echo 'test';
?>
Any ideas what might be the cause of this problem?
EDIT Our server manager mentioned something about apache not responding to localhost, does that perhaps ring a bell?
Thank you
Are you sure the URL is actually correct? Have you tried using $_SERVER ['HTTP_HOST']
instead? On the machine that runs PHP, what does the host from the generated URL resolve to? Has your web server (Apache?) been set up listen on the localhost interface?