473,387 Members | 1,882 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,387 software developers and data experts.

extra newlines in output text added by PHP file include

I have a simple PHP script that outputs a string requested by an Ajax
page. XMLHttpRequestObject.responseText as received from the PHP script
begins with 2 extra newline characters (\n\nMyString):

<?php
require_once('DB.php');
require_once('../myDir/myFile.php');
.......
echo('MyString');
?>

myFile
<?php
$var1 = 1;
$var2 = 2;
$var3 = 3;
?>

If I manually write the contents of myFile.php into the script, there
are no extra newlines in responseText.
Am I missing something?
Thanks!

Andrew

Nov 12 '06 #1
1 2477
On 12 Nov 2006 05:39:25 -0800, ab****@yahoo.com wrote:
>I have a simple PHP script that outputs a string requested by an Ajax
page. XMLHttpRequestObject.responseText as received from the PHP script
begins with 2 extra newline characters (\n\nMyString):

<?php
require_once('DB.php');
There's probably one at the start or end of DB.php.
>require_once('../myDir/myFile.php');
There's probably one at the start or end of this one too, which would make two
newlines.

If the included PHP file ends in a new line immediately after the closing ?>,
then it won't be sent. This is recommended else tools such as diff get upset.

If there's an additional blank line after that, then that will get sent.

Also be careful with the difference between Windows line endings and UNIX line
endings, as that can confuse the issue.

--
Andy Hassall :: an**@andyh.co.uk :: http://www.andyh.co.uk
http://www.andyhsoftware.co.uk/space :: disk and FTP usage analysis tool
Nov 12 '06 #2

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

Similar topics

4
by: Sidharta | last post by:
Hi all, how come this doesn't work????? # convert to unix new lines $text = preg_replace("/\r\n/", "\n", $text); # remove extra new lines $text = preg_replace("/\n+/", "\n", $text); is...
3
by: Wondiws | last post by:
Hi, I have the following code, which is supposed to open a file where 0a (hex) is used to mark a newline, and change this into 0d0a. But it places two 0d's before every 0a. Could somebody tell...
6
by: dbee | last post by:
So I can't seem to urlencode a file with newlines ... it just gives me a series of T_STRING unexpected parse errors... cat job_description | while read file ; do php -r "echo...
1
by: dbee | last post by:
Hi, So I'm having a problem with disappearing newlines. I import the newlines from a file into my shell script fine. But then I process the text and the url_encode comes out the other end with...
0
by: ccallen | last post by:
How to print msbuild <Messageto the VS 2005 output window, from an msbuild file that is loaded into VS? After reading Don Boxs' "MSBuild for MAKEFILE converts" , I copied the snippet, for point...
2
by: ricky | last post by:
Can anybody help with the function to get rid of extra characters in the file. I want to remove the string from the file.So i read from input file and pass the string say "john" if found dnt write...
1
by: abrtlt | last post by:
I have a simple PHP script that sends a string to XMLHttpRequestObject.responseText. responseText as received from the PHP script begins with 2 extra newline characters (\n\nMyString): <?php...
2
by: keeps21 | last post by:
Hi I have a script that checks whether a user is logged in or not. If the user are not logged in they are directed to the login page. else the user is logged in. If the user is logged in...
3
by: joelkeepup | last post by:
Hi, im trying to create a text email message using xslt template , the transforms work great, but the newlines and whitespace in the xslt doc are removed. Is there a setting somewhere I have...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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...

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.