Jump to content

require_once() please help...


fry2010

Recommended Posts

This is a re-occuring problem for me, I have managed to get around it before but I actually accidentilly removed the file that had the solution, at least I think it had a solution.

 

Basically when I use a require_once() function in a php file that I use with my ajax function to create text nodes, elements etc, I get a /n (new line) occur when I produce an output. When I remove the require_once() function the problem goes away.

 

Now I *can* get around this but its really ugly and a pain in the ass.

 

Here is the basics of my ajax function:

 

  
  this.process = function()
  {
    self.ajax.doGet('my_php_handler_file.php', self.handler_function);
  };

  this.handler_function = function(str)
  {
    if(str)
    {
       alert('TRUE!');
    }
    else
    {
       alert('FALSE!');
    }
  };

 

Here is the basic php file:

 

<?php require_once('file.php');  //THIS IS THE PROBLEM

    $bool = false;

    header('Content-Type: text/plain');
    print $bool;
?>

 

Basically it is returning this:  '/n false'

 

when i remove the require_once() it returns this:  'false'

 

which is what i need, and it does it for every single value I return for other things.

Link to comment
Share on other sites

yes I have done this, it seems to be the common problem when using an include in the php handler file, from other searches I have done.

 

I have even created a blank <?php ?> file for the require_once('blank.php') file so there is nothing in it and it does the same thing.

 

I have also tried this in the php handler file:

 

<?php require_once('blank.php');
?><?php
// DO CODE HERE
header('Content-Type: text/plain');
print $var;?>

 

and chopped and changed things around to try and remove what could be causing the new line, but the only thing that works is removing the require function. I think there must be somthing which is causing this if other people are able to get a require function working, but I cant find it.

thanks for the suggestion.

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.