473,387 Members | 3,801 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 \r\n using include() on wamp

Hi all,
I use WAMP server 2, php 5.2.8
This code
Expand|Select|Wrap|Line Numbers
  1.   echo "1";
  2. include(mnminclude.'html1.php');
  3. echo "2";
  4.  
prints out "1\r\n2" even though there are only functions in html1.php file but no echo statement.

When run on a linux server, there are no extra "\r\n". I assume this is wamp/apache behavior and not php behavior. How do people who develop on WAMP and deploy on Linux deal with these types of string issues?

Thanks,

Jack
Mar 2 '09 #1
5 2639
Markus
6,050 Expert 4TB
I imagine there is something inside that file that is outputting the carriage return and new line characters. Can we see what's in there?
Mar 2 '09 #2
Dormilich
8,658 Expert Mod 8TB
note:though it is not required, it is always good practice to write constants in upper case, makes them easy to identify.
Mar 2 '09 #3
Thanks. Code looks like this. The extra CRLF after the closing <?php> code... <?> is the source of the problem.
I wonder why this is only a problem in WAMP but not on Linux. Further, I would think there would need to be explicit echo calls to output to responsetext, rather than just random \r\n at the end of the included files.

Expand|Select|Wrap|Line Numbers
  1.               url = $thisurl + '/checkfield.php?type='+type+'&name=' + field.value;
  2.               checkitxmlhttp = new myXMLHttpRequest ();
  3.               checkitxmlhttp.open ("GET", url, true);
  4.               checkitxmlhttp.onreadystatechange = function () {
  5.                       if (checkitxmlhttp.readyState == 4) {
  6.                       responsestring = checkitxmlhttp.responseText;
  7.  
Expand|Select|Wrap|Line Numbers
  1.  
  2.       //checkfield.php -------------------------------------
  3.       include_once('Smarty.class.php');
  4.       $main_smarty = new Smarty;
  5.       echo "1";
  6.       include('config.php');
  7.       echo "2";
  8.       include(mnminclude.'html1.php');
  9.       echo "3";
  10.  
//output --------------------------------------------
"1\r\n\r\n2\r\n3"
Mar 2 '09 #4
Atli
5,058 Expert 4TB
@cwjacklin
It could be anything from the way the operating-systems handles files to the way your PHP editor saves files. (Some of them trim trailing white-spaces, some don't).

It's best just to make sure there is no room for misinterpretation by not leaving white-spaces where they shouldn't be.

@cwjacklin
Anything outside <?php ?> tags is usually considered HTML by Apache and added to the output accordingly.
Consider this:
Expand|Select|Wrap|Line Numbers
  1. <html>
  2. <head><title>Test</tile></head>
  3. <body>
  4.   <table>
  5.     <?php
  6.       for($i = 0; $i < 5; ++$i) {
  7.         echo "<tr>";
  8.         for($j = 0; $j < 5; ++$j) {
  9.           echo "<td>", pow($j, $i), "</td>";
  10.         }
  11.         echo "</tr>";
  12.       }
  13.     ?>
  14.   </table>
  15. </body>
  16. </html>
If nothing unless the echo statements made it to the output, this type of syntax could not be used.

And keep in mind that a HTML infused PHP code like that is often included. In fact, I'm pretty sure the Smarty template engine does a lot of that.
Mar 3 '09 #5
Well, the issue is say I have some code that expects well formatted XML. And then I add a module which has extra \r\n in the php file. Now those \r\n makes the XML un-parse-able. It's possible to catch this, but not a pretty solution, especially if you don't have control over 3rd party modules.

I have searched around, I am surprised that I haven't found other people with this issue.
Mar 3 '09 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Bill | last post by:
I have perhaps not explained myself clearly, so I'll try it this way. In the code below, where it says "I'd like to include my navigation bar here" is the place I'd like to insert a navigation bar...
6
by: Till Crueger | last post by:
Hi, I know you shouldn't do this, but I just thought of a really nasty way to obfuscate c code. I am however not sure if this is correct c at all. What I did was this: file obfuscate.c:...
1
by: Wallace | last post by:
Hi all, I have a problem on validating a xml fragment using a single namespace schema which spread across multiple schema files using include in the master schema file. No matter how I change...
1
by: ABITECH | last post by:
hi guys I am working on a project in databases using the wamp software. So how do i connect msql to php. Pliz help mi Because i badly nid the code for my project. bye
3
by: runway27 | last post by:
i am doing seo for a website and this website uses a lot of php for which i need suggestions. this is how the website is set up. in the index.php file there is a flash banner at the top of the...
5
by: chris_peoples | last post by:
I have a virtual directory, lets say it exists at www.server-a.com/virtual-dir/ virtual-dir points to another directory on another server using the unc path: \\server-b\main-dir I have a file at...
0
by: deegeorge | last post by:
Hi, can i insert a word document using include directive in asp.net. Can u please give a simple example code Thanks in advance
4
by: aswathip | last post by:
When i tried to include multiple files using include() it didn't work as expected. catagorization.php includes the following code include("ajax_catagorization.php"); ...
2
by: dragonflie | last post by:
Recently I installed WAMP 2.0 and I tried to view the index.php in Firefox; however I'm told windows cannot open this file. The prompt ask "What do you want to do?" "Use the Web service to find the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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,...

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.