473,545 Members | 2,444 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Extra \r\n using include() on wamp

4 New Member
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 2653
Markus
6,050 Recognized Expert Expert
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 Recognized Expert Moderator Expert
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
cwjacklin
4 New Member
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\n 3"
Mar 2 '09 #4
Atli
5,058 Recognized Expert Expert
@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 misinterpretati on 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
cwjacklin
4 New Member
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
1849
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 from a page I have called navbar.asp For some reason, when I insert the <! #include file="navbar.asp" --> in that place, I get an error, a long,...
6
1767
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: #include <stdio.h> int main(int argc, char* argv){ #include "obfuscate.h"
1
2293
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 the xml fragment (to include default namespace xmlns='urn:xxx:yy' and any other namespace it may have), I still get the same error. ...
1
1555
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
1315
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 page and the center part is another file which is called using include("links.php") and the bottom part using include("footer.php") the footer has...
5
4561
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 www.server-a.com/virtual-dir/some_script.asp, using the following include: <!--#include file="some_include.asp"---> Going to...
0
1033
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
1519
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"); include("categorization_total.php"); This way it does not work. But if only one file is included it works properly Can anybody please help me to solve this?
2
2245
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 appropriate program". I saw a youtube tutorial that actually showed the file opening up correctly in Firefox. What is wrong...Why can't I veiw...
0
7490
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7425
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
1
7449
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7780
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
5069
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3479
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
1911
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1037
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
734
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.