|
-
Jul 2nd, 2008, 02:32 PM
#1
file(URL) causes a blank page
One of my websites on a shared host has started behaving strangely. The file() function won't work when calling a URL. Here is what I tried, straight from php.net/function.file.
PHP Code:
start
<?
// Get a file into an array. In this example we'll go through HTTP to get // the HTML source of a URL. $lines = file('http://www.mendhak.com/default.aspx');
?>
finish
The page comes out as blank for any URL. It gives an HTTP 200, but there is no markup at all when viewing source. Is there a way to make the page not depend on what's coming back from the HTTP request? I've also tried a try catch, still blank response.
PHP Code:
start
<?
try {
// Get a file into an array. In this example we'll go through HTTP to get // the HTML source of a URL. $lines = file('http://www.vbforums.com/index.php'); } catch(Exception $e) { echo ('exception'); }
?>
finish
The server is using PHP 5.2.5.
Another question - I can do a phpinfo(), but is there anything in phpinfo() that I can look at to see whether such web requests are allowed or not?
-
Jul 2nd, 2008, 02:57 PM
#2
Re: file(URL) causes a blank page
What do you get if you do var_dump($lines)? The setting you need is allow_url_fopen
-
Jul 3rd, 2008, 01:07 AM
#3
Re: file(URL) causes a blank page
Exactly the same as before. The presence of fopen on the page causes a blank response. I checked phpinfo and much to my chagrin, allow_url_fopen is set to On.
Now I'm losing hope. Thanks. Again.
-
Jul 3rd, 2008, 03:44 AM
#4
Re: file(URL) causes a blank page
A blank page "should" only be encountered when you have got error report set to off. Have a look at the error reporting settings in phpinfo and if you are not sure stick the following line at the top of the script:
PHP Code:
error_reporting(E_ALL);
-
Jul 3rd, 2008, 05:15 AM
#5
Re: file(URL) causes a blank page
 Originally Posted by visualAd
A blank page "should" only be encountered when you have got error report set to off.
or if you're doing output buffering and an error somehow causes the buffer to be cleaned instead of flushed (admittedly, this is rather far-fetched — I don't think it can happen without writing code to do it).
-
Jul 3rd, 2008, 06:41 AM
#6
Re: file(URL) causes a blank page
Error reporting is already set to E_ALL. Sorry I didn't mention that. Then again it would've been caught in the catch() block, wouldn't it? I'm going to let this question/functionality drop for now, I'll revisit it later if required. Thanks for your time.
-
Jul 3rd, 2008, 06:49 AM
#7
Re: file(URL) causes a blank page
PHP errors are not exceptions, so no. The other settings you should look out for it the error_log and display_errors setting which controls other aspects of error control.
You are making it very difficult to help you as there are no errors.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|