I have two computers. I set up a web server on both computers and both of them work. Now I want to get the 1st URL from the second using file_get_contents().
1st URL:
http://46.7.234.111:8080/server/test_curl.php
2nd URL:
http://spicegururathgar.ie/client/test_curl.php
Code for accessing the 1st URL:
$url = "http://46.7.234.111:8080/server/test_curl.php";
$url = 'http://' . str_replace('http://', '', $url);
$opts = array('http' => array('header' => "User-Agent:MyAgent/1.0\r\n"));
$context = stream_context_create($opts);
$header = file_get_contents('$url', false, $context);
Apache Error Log:
[27-Dec-2013 08:31:12 UTC] PHP Warning: file_get_contents(http:
How can I access other files using file_get_contents(), but not the one I want. So please help me solve this problem.
I checked the entire PHP configuration on both servers, but if someone wants to check, use the following URLs:
http://46.7.234.111:8080/phpinfo.phphttp://spicegururathgar.ie/phpinfo.php
Please ignore the file names;)
Im only encounters this problem when Im trying to run code from the server spicegururathgar.ie, does anyone know why this is happening?
Alternative try
PHP CURL, Im . PHP CURL. localhost, . , .
$runfile = "http://46.7.234.111:8080/server/test_curl.php";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $runfile);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_URL,$runfile);
$content = curl_exec($ch);
curl_close($ch);
echo $content;