Reputation: 545
how can i get php file contents with php or js file from other server
with allow_url_fopen ON ?
i try this first - ITS WORK but from my server !
<?php
$url = "index.php";
$json = file_get_contents($url);
echo $json;
echo 1;
?>
i its not work
<?php
$url = "http://mysite.com/index.php";
$json = file_get_contents($url);
echo $json;
echo 1;
?>
anyone know how get file content with allow_url_fopen from other server?
or other user from my server?
or get variable from that file?
Upvotes: 0
Views: 1043
Reputation: 522076
How a file is opened depends on the stream wrapper, which depends on the full URL.
file_get_contents('index.php')
defaults to the local file system wrapper, i.e. it opens the file directly from the hard disk and reads its contents.
file_get_contents('http://example.com/index.php')
uses the HTTP stream wrapper. You cannot access the file on the hard disk of another server directly (hopefully you can't). Opening http://example.com/index.php
is the same as putting that URL into your browser: it makes an HTTP request to that URL and the result is whatever the other server outputs after processing the PHP file, like with any regular web request.
Upvotes: 2