Hi all,
I use WAMP server 2, php 5.2.8
This code -
echo "1";
-
include(mnminclude.'html1.php');
-
echo "2";
-
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
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?
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.
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. -
url = $thisurl + '/checkfield.php?type='+type+'&name=' + field.value;
-
checkitxmlhttp = new myXMLHttpRequest ();
-
checkitxmlhttp.open ("GET", url, true);
-
checkitxmlhttp.onreadystatechange = function () {
-
if (checkitxmlhttp.readyState == 4) {
-
responsestring = checkitxmlhttp.responseText;
-
-
-
//checkfield.php -------------------------------------
-
include_once('Smarty.class.php');
-
$main_smarty = new Smarty;
-
echo "1";
-
include('config.php');
-
echo "2";
-
include(mnminclude.'html1.php');
-
echo "3";
-
//output --------------------------------------------
"1\r\n\r\n2\r\n 3"
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: -
<html>
-
<head><title>Test</tile></head>
-
<body>
-
<table>
-
<?php
-
for($i = 0; $i < 5; ++$i) {
-
echo "<tr>";
-
for($j = 0; $j < 5; ++$j) {
-
echo "<td>", pow($j, $i), "</td>";
-
}
-
echo "</tr>";
-
}
-
?>
-
</table>
-
</body>
-
</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.
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.
Sign in to post your reply or Sign up for a free account.
Similar topics |
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,...
|
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"
|
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.
...
|
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
|
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...
| |
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...
|
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
|
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?
|
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...
|
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...
|
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...
| |
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...
|
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...
|
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...
|
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...
|
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
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
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...
| |