473,399 Members | 3,656 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

file_get_contents outputs nothing

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?

Thanks

Taras

Oct 25 '07 #1
6 6920
Taras_96 <ta******@gmail.comwrote in news:1193323567.561939.158410
@y27g2000pre.googlegroups.com:
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 have an error somewhere and error_reporting is set to off.
Oct 25 '07 #2
On Oct 25, 11:40 pm, Good Man <he...@letsgo.comwrote:
Taras_96 <taras...@gmail.comwrote in news:1193323567.561939.158410
@y27g2000pre.googlegroups.com:
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 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
Oct 25 '07 #3
Taras_96 <ta******@gmail.comwrote in
news:11*********************@k35g2000prh.googlegro ups.com:
On Oct 25, 11:40 pm, Good Man <he...@letsgo.comwrote:
>Taras_96 <taras...@gmail.comwrote in news:1193323567.561939.158410
@y27g2000pre.googlegroups.com:
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 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
Oct 25 '07 #4
On Thu, 25 Oct 2007 16:46:07 +0200, Taras_96 <ta******@gmail.comwrote:
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'll 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.aspx");
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
Oct 25 '07 #5
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.

Oct 25 '07 #6
On Oct 26, 3:02 am, "Rik Wasmus" <luiheidsgoe...@hotmail.comwrote:
On Thu, 25 Oct 2007 16:46:07 +0200, Taras_96 <taras...@gmail.comwrote:
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'll 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 would do the trick :D

Thanks all for your suggestions

Taras

Oct 26 '07 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Rob | last post by:
for some reason i keep getting : Warning: file_get_contents(): php_network_getaddresses: getaddrinfo failed: Temporary failure in name resolution in /home/rob/www/php/filegetcontents2.php on...
4
by: Sarah Haff | last post by:
Hi, What would be minimilistic XSLT that does "nothing" (no transformation) to the given XML content. Thank you. Sarah Haff
1
by: jjainschigg | last post by:
I'm running PHP 5 on a shared VPS. I have a couple little apps that are using file_get_contents() and readfile() for various kinds of (what should be) low-overhead, fast outbound accesses ... that...
5
by: howa | last post by:
are there any advantage in replacing all fread() operations with file_get_contents() ? i.e. file_get_contents("/usr/local/something.txt") VS $filename = "/usr/local/something.txt";
4
by: Aetherweb | last post by:
This is probably really obvious, sorry, been a long day... I'm wanting to create a PHP file which is a template for an email, and read the file into a string, ready to send out using my email...
9
by: howa | last post by:
Target: To fetch a file using PHP and send to user Method 1: echo file_get_contents( $file_path ); Method 2: readfile( $file_path );
5
by: mmarlow | last post by:
Hi all, I'm trying to get the contents of a file from a URL using file_get_contents() or file(). It doesn't work, it eventually just times out. It used to display a 'failed to open file' message...
0
by: pac1250 | last post by:
Hi, I am searching how to solve a problem and I dont find it :( I want to access a page from a script behind a proxy : (my script) <-(a proxy with authentification) <-(https serveur with...
6
by: Pheddy | last post by:
Hey i tried this code to get the country and IP via PHP (from: http://roshanbh.com.np/2008/07/getting-country-city-name-from-ip-address-in-php.html) function countryCityFromIP($ipAddr) {...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.