473,728 Members | 1,550 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

newline \n and tab \t Not Working in PHP 5.0.3 | Apache 2.0.52 | Windows XP Pro

The following examples (see PHP 5 for Dummies, p. 82)
do not produce the expected results:

$string = "Hello \nWorld";
echo $string;

and

$string = "Line 1 \n\tLine 2";
echo $string;

The first instance is for a line break such that the words are stacked:

Hello
World

The second instance is for a line break with a tabbed second line:

Line 1
Line 2

Do I need to change or add something in one of the configuration files?
Otherwise, is there a known fix for this? Thank you for any assistance.

Jul 17 '05 #1
7 15268
ga*****@cwnet.c om wrote:
The following examples (see PHP 5 for Dummies, p. 82)
do not produce the expected results:

$string = "Hello \nWorld";
echo $string;

and

$string = "Line 1 \n\tLine 2";
echo $string;

The first instance is for a line break such that the words are
stacked:

Hello
World

The second instance is for a line break with a tabbed second line:

Line 1
Line 2

Do I need to change or add something in one of the configuration
files?
Otherwise, is there a known fix for this? Thank you for any
assistance.


Newlines and tabs are ignored by browsers when rendering HTML. If you
view the source of the page in your browser you will see the tabs and
newline breaks are there.

To do a line break in HTML you need to use the <br /> tag, or enclose
your sentance in <p> and </p> tags.

--
Chris Hope - The Electric Toolbox - http://www.electrictoolbox.com/
Jul 17 '05 #2
I noticed that Message-ID:
<11************ *********@l41g2 000cwc.googlegr oups.com> from
ga*****@cwnet.c om contained the following:
The following examples (see PHP 5 for Dummies, p. 82)
do not produce the expected results


I'd be interested to see what the book actually says the code does...

--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/
Jul 17 '05 #3
The book says the code should produce the two results shown in my
original post (which are copied there from the book). These expected
results appear below the examples in my post, a little farther down in
its text, as "first instance" and "second instance"--i.e., the first
result is to provide a line break (newline \n), and the second result
is to provide both a line break and a tab (newline tab n\t\).

Jul 17 '05 #4
ga*****@cwnet.c om wrote:
The book says the code should produce the two results shown in my
original post (which are copied there from the book). These expected
results appear below the examples in my post, a little farther down in
its text, as "first instance" and "second instance"--i.e., the first
result is to provide a line break (newline \n), and the second result
is to provide both a line break and a tab (newline tab n\t\).


It should provide the expected results when you use View Source to see
the raw HTML code. However, when the browser displays the page it will
ignore the extra whitespace (spaces, tabs, and newlines are all whitespace).
Jul 17 '05 #5
Thank you.

It seems that the usefulness of the \n and \t features is limited to
formatting source code for easy readability.

It looks like <p></p> tags would be the best choice for onscreen
formatting. I imagine using CSS classes in them would permit such
things as the equivalent of tabbing, in addition to the default line
breaks.

Jul 17 '05 #6
ga*****@cwnet.c om wrote:
The following examples (see PHP 5 for Dummies, p. 82)
do not produce the expected results:

$string = "Hello \nWorld";
echo $string;

and

$string = "Line 1 \n\tLine 2";
echo $string;

The first instance is for a line break such that the words are stacked:

Hello
World

The second instance is for a line break with a tabbed second line:

Line 1
Line 2

Do I need to change or add something in one of the configuration files?
Otherwise, is there a known fix for this? Thank you for any assistance.


Since browsers collapse all consecutive whitespace to a single space by
default, you could do this:

echo '<pre>';
echo $string;
echo '</pre>';

HTH,
JP

--
Sorry, <de*****@cauce. org> is a spam trap.
Real e-mail address unavailable. 5000+ spams per month.
Jul 17 '05 #7
*** ga*****@cwnet.c om escribió/wrote (13 Feb 2005 19:35:33 -0800):
Do I need to change or add something in one of the configuration files?


If you are expecting plain text output, add this to the very beginning of
the file:

header('Content-Type: text/plain');
--
-+ Álvaro G. Vicario - Burgos, Spain
+- http://www.demogracia.com (la web de humor barnizada para la intemperie)
++ Manda tus dudas al grupo, no a mi buzón
-+ Send your questions to the group, not to my mailbox
--
Jul 17 '05 #8

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

Similar topics

5
2430
by: Nuno Paquete | last post by:
Hi group. How can I get PHP working under windows, with Apache web server? Where can I find the module? I suppose that I need to install a module like in Linux... Thanks in advance. Nuno Paquete
10
1735
by: sp | last post by:
The application is written in Visual Basic / .NET and working without problems under Windows XP, Windows 2000, Windows 2003 but it isn't working under Windows ME and Windows 98 - the computer hangs. After computers hangs you can move mouse but can not press any key. Alt - Ctrl- Del isn’t working so you have to reset the computer by pressing button. I checked several Win 98 and Me - clean install to - always the same! At the beginning...
4
4876
by: arorap | last post by:
I've mod_php installed with Apache 2.2. In one of my folders, I'm using the cgihandler as the PythonHandler as my target host runs python only as CGI. Here cgi.FieldStorage() doesn't seem to work. I can see the form data in sys.stdin but cgi.FieldStorage() returns an empty dictionary. Here's the code for the test script I am posting to - -- #!/usr/bin/python
4
3594
by: tekeste | last post by:
Hello guys. is there someone out there to tell me why TAB key is not working in windows CE mobile application in .net? I just want to move from one textbox to the next using TAB key, but it won't work at all. Please help
2
1263
by: abhilash12 | last post by:
hai ajax is not working in windows nt machine in nt machine status=501 so pls help me
1
1838
by: Gowri | last post by:
Hello, I am new to Python and am trying to setup Apache to serve Python using mod_python. I'm using a Windows XP box. here is a list of steps i followed for the installation: 1. Installed Apache 2.2.6 2. Installed Python 2.5.1 3. Installed mod_python 3.3.1
4
6698
by: adnanjunk | last post by:
Hi, Having a little issue with .htaccess not working on windows server. I have clean url's setup using the htaccess file, working fine on linux server. I have researched for a while and found .htaccess doesn't work on windows. Since this is a shared hosting i don't have access to httpd.conf so that i can edit it. I have been reading this forum about it. http://forum.mambo-foundation.org/showthread.php?t=1857
6
7598
by: josequinonesii | last post by:
I've searched, I've read, I've tested and re-read numerous post but to no avail yet... Quite simply, the settings I've applied to my httpd.conf, httpd-vhost.conf and my hosts files simply does not work. Please review my work and let me know if you see that one little thing that is throwing me for a loop. HTTPD.CONF # # This is the main Apache HTTP server configuration file. It contains the # configuration directives that give the...
0
8896
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 usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8755
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9416
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8121
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6710
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6012
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 into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4787
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3231
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
3
2159
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.