file_get_contents outputs nothing
file_get_contents outputs nothing
am 25.10.2007 16:46:07 von Taras_96
Hi everyone,
The output of
echo file_get_contents("http://watchout4snakes.com/creativitytool s/
RandomWord/RandomWordPlus.aspx");
leaves the browser empty.. no error messages, nothing.
Why is this occurring?
Thanks
Taras
Re: file_get_contents outputs nothing
am 25.10.2007 17:40:16 von Good Man
Taras_96 wrote in news:1193323567.561939.158410
@y27g2000pre.googlegroups.com:
> Hi everyone,
>
> The output of
>
> echo file_get_contents("http://watchout4snakes.com/creativitytool s/
> RandomWord/RandomWordPlus.aspx");
>
> leaves the browser empty.. no error messages, nothing.
>
> Why is this occurring?
presumably you have an error somewhere and error_reporting is set to off.
Re: file_get_contents outputs nothing
am 25.10.2007 20:49:44 von Taras_96
On Oct 25, 11:40 pm, Good Man wrote:
> Taras_96 wrote in news:1193323567.561939.158410
> @y27g2000pre.googlegroups.com:
>
> > Hi everyone,
>
> > The output of
>
> > echo file_get_contents("http://watchout4snakes.com/creativitytool s/
> > RandomWord/RandomWordPlus.aspx");
>
> > leaves the browser empty.. no error messages, nothing.
>
> > Why is this occurring?
>
> presumably you have 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
Re: file_get_contents outputs nothing
am 25.10.2007 21:00:51 von Good Man
Taras_96 wrote in
news:1193338184.455469.86540@k35g2000prh.googlegroups.com:
> On Oct 25, 11:40 pm, Good Man wrote:
>> Taras_96 wrote in news:1193323567.561939.158410
>> @y27g2000pre.googlegroups.com:
>>
>> > Hi everyone,
>>
>> > The output of
>>
>> > echo file_get_contents("http://watchout4snakes.com/creativitytool s/
>> > 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 have
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
Re: file_get_contents outputs nothing
am 25.10.2007 21:02:50 von luiheidsgoeroe
On Thu, 25 Oct 2007 16:46:07 +0200, Taras_96 wrote:=
> Hi everyone,
>
> The output of
>
> echo file_get_contents("http://watchout4snakes.com/creativitytool s/
> 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'll have to mimique a common UA with for =
instance CURL to get it to output anything. This works:
$ch =3D curl_init();
curl_setopt($ch, CURLOPT_URL, =
"http://watchout4snakes.com/creativitytools/RandomWord/Rando mWordPlus.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
Re: file_get_contents outputs nothing
am 25.10.2007 21:03:43 von Macca
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.
Re: file_get_contents outputs nothing
am 26.10.2007 06:59:36 von Taras_96
On Oct 26, 3:02 am, "Rik Wasmus" wrote:
> On Thu, 25 Oct 2007 16:46:07 +0200, Taras_96 wrote:
> > Hi everyone,
>
> > The output of
>
> > echo file_get_contents("http://watchout4snakes.com/creativitytool s/
> > 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'll have to mimique a common UA with for
> instance CURL to get it to output anything. This works:
>
>
> $ch = curl_init();
>
> curl_setopt($ch, CURLOPT_URL,
> "http://watchout4snakes.com/creativitytools/RandomWord/Rando mWordPlus....");
> 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 would do the trick :D
Thanks all for your suggestions
Taras