Sagewire Logo

file_get_contents outputs nothing

7 Message(s) by 4 Author(s) originally posted in php programming


From: Taras_96 Date:   Thursday, October 25, 2007
Hi everyone,

The output of

echo file _get_contents("http://watchout4snakes.com/creativitytools/
RandomWord/RandomWordPlus.aspx");

leaves the browser empty.. no error message s, nothing.

Why is this occurring?

Thanks

Taras


From: Good Man Date:   Thursday, October 25, 2007
wrote in message in
@xxxxxxxxxxx:

Hi everyone,
The output of
echo file_get_contents("http://watchout4snakes.com/creativitytools/
RandomWord/RandomWordPlus.aspx");
leaves the browser empty.. no error messages, nothing.
Why is this occurring?



presumably you've an error somewhere and error_reporting is set to off.


From: Taras_96 Date:   Thursday, October 25, 2007
wrote in message:
wrote in message in
@xxxxxxxxxxx:
> Hi everyone,
> The output of
> echo file_get_contents("http://watchout4snakes.com/creativitytools/
> RandomWord/RandomWordPlus.aspx");
> leaves the browser empty.. no error messages, nothing.
> Why is this occurring?
presumably you've an error somewhere and error_reporting is set to off.

From my php.ini



error_reporting = E_ALL|E_STRICT

; Print out errors (as a part of the output). For production web
sites,
; you're strongly encouraged to turn this feature off, and use error
logging
; instead (see below). Keeping display_errors enabled on a production
web site
; may reveal security information to end users, such as file paths on
your Web
; server, your database schema or other information.
display_errors = On


From: Good Man Date:   Thursday, October 25, 2007
wrote in message in


wrote in message:
wrote in message in
@xxxxxxxxxxx:

> Hi everyone,

> The output of

> echo file_get_contents("http://watchout4snakes.com/creativitytools/
> RandomWord/RandomWordPlus.aspx");

> leaves the browser empty.. no error messages, nothing.

> Why is this occurring?



This is on the manual page for file_get_contents, is this why? do you've
fopen wrappers enabled?You can use a URL as a filename with this function if the fopen wrappers
have been enabled. See fopen() for more details on how to specify the
filename and Appendix O, List of Supported Protocols/Wrappers for a list of
supported URL protocols.
http://ca.php.net/file_get_contents


From: Rik Wasmus Date:   Thursday, October 25, 2007
wrote in message:=> Hi everyone,
The output of
echo file_get_contents("http://watchout4snakes.com/creativitytools/
RandomWord/RandomWordPlus.aspx");
leaves the browser empty.. no error messages, nothing.
Why is this occurring?



It's a badly designed website/server, which apparently applies browser =

sniffing of some sort. You will have to mimique a common UA with for =

instance CURL to get it to output anything. This works:

<?php
$ch =3D curl_init();

curl_setopt($ch, CURLOPT_URL, =

"http://watchout4snakes.com/creativitytools/RandomWord/RandomWordPlus.as=
px");
curl_setopt($ch,CURLOPT_USERAGENT,'Mozilla/5.0 (Windows ; U; Windows NT =

5.2; en-GB; rv:1.8.1.7) Gecko/20070914 Firefox/2.0.0.7');

curl_exec($ch);
curl_close($ch);
?>


.. without setting the CURLOPT_USERAGENT the site indeed outputs nothing=
.
-- =

Rik Wasmus


From: macca Date:   Thursday, October 25, 2007
Okay I just tried this with readfile.$path = 'http://watchout4snakes.com/creativitytools/RandomWord/
RandomWordPlus.aspx';

echo readfile($path);Now, readfile returns the number of bytes read from the file or false
on failure and this outputs '0'.

This leads me to believe that the problem is something to do with the
aspx page not the php code.


From: Taras_96 Date:   Friday, October 26, 2007
wrote in message:
wrote in message:
> Hi everyone,
> The output of
> echo file_get_contents("http://watchout4snakes.com/creativitytools/
> RandomWord/RandomWordPlus.aspx");
> leaves the browser empty.. no error messages, nothing.
> Why is this occurring?
It's a badly designed website/server, which apparently applies browser
sniffing of some sort. You will have to mimique a common UA with for
instance CURL to get it to output anything. This works:
<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,
"http://watchout4snakes.com/creativitytools/RandomWord/RandomWordPlus....");
curl_setopt($ch,CURLOPT_USERAGENT,'Mozilla/5.0 (Windows; U; Windows NT
5.2; en-GB; rv:1.8.1.7) Gecko/20070914 Firefox/2.0.0.7');
curl_exec($ch);
curl_close($ch);
?>

.. without setting the CURLOPT_USERAGENT the site indeed outputs nothing.
--
Rik Wasmus



Yep, that'd do the trick :D

Thanks all for your suggestions

Taras



Next Message: Is it Daylight Savings Time ?



Programming | Sports | Autos

copyright 2006
Valid XHTML 1.0 Transitional