why i not getting return on file_get_contents($myurl) but i do get output for wget
updated:
i use curl to get the return header and result and discovery that the it is on the header instead in of the body
HTTP/1.1 200 Document follows
Transfer-Encoding: chunked
Content-type: text/plain
Server: XMS (724Solutions HTA XSAM_30_M2_B020 20070803.172831)
Date: Fri, 21 May 2010 10:48:31 GMT
Accept-Ranges: bytes
HTTP/1.1 404 ChargedPartyNotAvailable
Transfer-Encoding: chunked
Content-type: text/plain
Server: XMS (724Solutions HTA XSAM_30_M2_B020 20070803.172831)
Date: Fri, 21 May 2010 10:34:13 GMT
Accept-Ranges: bytes
How can i extract out only "200 Document Follow" and "404 ChargedPartyNotAvailable" ?
Do you have allow_url_fopen enabled in your php configuration?
However I would expect that you would get a warning generated if not - do you have errors/warnings displayed? You could add temporarily at the top of your script :
error_reporting(E_ALL);
ini_set('display_errors', true);
and then you might see why file_get_contents() doesn't work.
Edit
You might just be able to use get_headers()
if you're only interested in headers.
You can use PHP Curl package to retrieve the content of URL
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$myUrl);
$result = curl_exec($ch);
curl_close($ch);
Or if you want to use only file_get_contents, check if you configured PHP.ini correctly
http://www.php.net/manual/en/filesystem.configuration.php#ini.allow-url-fopen
As mentioned here (http://php.net/manual/en/function.file-get-contents.php)
A URL can be used as a filename with
this function if the fopen wrappers
have been enabled. See fopen() for
more details on how to specify the
filename.
You could try:
$contents = implode('', file($myurl));
I use it very often.