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
https://forums.phpfreaks.com/topic/161201-require_once-please-help/
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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.