Jump to content

Empty page outputting "0"


nx2wes

Recommended Posts

I'm running into a weird problem I've never experienced before.

 

I recently switched to Netfirms hosting... I'm running PHP5.  Now, for some reason, any blank pages with PHP tags are outputting 0.

 

So, for example,

<?php ?>

will output

0

 

If there's any output whatsoever, this doesn't happen.... So

<?php echo " "; ?>

outputs

 

This also doesn't happen with blank HTML pages... they just output a blank page, no 0.

 

This is screwing with my AJAX by making 0s pop up when there are no search results, etc.

 

I can modify my PHP.ini, but I have no idea what settings, etc., could be causing this behavior.  I appreciate any thoughts or help.

Link to comment
Share on other sites

If you post some of your code it may help. I have never really seen the "0" output, but the context can help. If all else fails, is there a problem just echoing a blank space?

 

<?php
echo ""; // or echo " ";
?>

 

Or another option is just check for "0" in your ajax script and handle it properly.

 

 

Link to comment
Share on other sites

Thanks for all of the replies.  I've sent a support ticket to my host; I'll let you know what they say.

 

After a little more exploration, I'm inclined to agree that this is probably an Apache issue.

 

Looks like I was putting a space in my test blank HTML page.  Once I removed that space, Apache returned a 404 error on the blank HTML page.  So, it looks like the server is configured to throw a 404 error for empty pages.  I'm guessing this has something to do with the "0" on PHP pages.  For some reason, when a page is sent through the PHP parser it's stopping the 404 error but returning a "0" when the parser output is empty.

 

@premiso: Echoing a blank space works.  I'll have to use that as a temporary work around for now.

Link to comment
Share on other sites

For an update:

 

My host basically denied that the problem exists (??).  It's not worth the fight, so I just implemented two work-arounds:

 

1. Echo " " on PHP pages providing AJAX results

2. Javascript checks for "0" and converts it to ""

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.