473,560 Members | 2,990 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Windows PHP 5.2.6 - Problems with Escape Characters

Hi,

I'm new to PHP and I am working through tutorials. I am running PHP
5.2.6, on windows xp. I am having problem with escape characters, they
do not seem to work. The below code example should display on multiple
lines, it just displays on 1 line no '\n' line breaks, it's ignored.
Is there something I need to set in the php.ini file? The php seems to
be installed fine as I can call functions etc.

<?php
$text = "A very long woooooooooooord .";
$newtext = wordwrap($text, 8, "\n", true);

echo "$newtext\n ";
?>
Thanks

Ned
Jun 2 '08 #1
3 1496
sc****@gmail.co m a écrit :
The below code example should display on multiple
lines, it just displays on 1 line no '\n' line breaks, it's ignored.
Is there something I need to set in the php.ini file? The php seems to
be installed fine as I can call functions etc.

<?php
$text = "A very long woooooooooooord .";
$newtext = wordwrap($text, 8, "\n", true);

echo "$newtext\n ";
?>
Are you trying it through your browser ? Cause then, it displays as
expected in the source code only, while your browser doesn't handle
newlines and display all lines concatenated.
You can easily change it by echoing nl2br("{$newtex t}\n"); (I prefer
using curly brackets into double-quoted strings)

Regards,
--
Guillaume
Jun 2 '08 #2
sc****@gmail.co m wrote:
Hi,

I'm new to PHP and I am working through tutorials. I am running PHP
5.2.6, on windows xp. I am having problem with escape characters, they
do not seem to work. The below code example should display on multiple
lines, it just displays on 1 line no '\n' line breaks, it's ignored.
Is there something I need to set in the php.ini file? The php seems to
be installed fine as I can call functions etc.

<?php
$text = "A very long woooooooooooord .";
$newtext = wordwrap($text, 8, "\n", true);

echo "$newtext\n ";
?>
Thanks

Ned

try

echo "<pre>$newtext\ n</pre>";

browsers may not treat \n as <brunless it is within the <pretags.
Jun 2 '08 #3
Thank you all very much.

Yep I was testing through the browser, your suggetions worked.

Thanks again.

Jun 2 '08 #4

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

Similar topics

7
96271
by: teachtiro | last post by:
Hi, 'C' says \ is the escape character to be used when characters are to be interpreted in an uncommon sense, e.g. \t usage in printf(), but for printing % through printf(), i have read that %% should be used. Wouldn't it have been better (from design perspective) if the same escape character had been used in this case too. Forgive me...
4
7462
by: Guadala Harry | last post by:
I need to place the following into a string... How can I properly escape the % " / < and > characters? <table width="100%" border="0" cellspacing="0" cellpadding="4px" class="hfAll"></Table> Thanks.
12
3855
by: Onega | last post by:
Hi I create a simple win32 project (VC2003, windows2003(English) , and do simple paint in WM_PAINT message, when the project use multi-character set, it is OK. but when I change to UNICODE, some Chinese characters are illegible( I see sizeof(TCHAR)=2 being displayed). Your idea is welcome. case WM_PAINT: hdc = BeginPaint(hWnd, &ps);
3
2227
by: Guadala Harry | last post by:
I'd like to know the answer to the following question so I can know what to expect with regard to other similar uses of escape characters and strings. While everything works fine - I'd like to know specifically why: I am building a simple HTML table in my C# code-behind by concatenating strings that contain different parts of the table and...
0
1465
by: Mike Cooper | last post by:
Hi everyone, I am accessing several binary (PCL) files sequentially using a for loop. For each file I am using the fileget() command to populate the contents of the file into a string. I use the following commands to do so: LengthofOverlay = FileLen(PCLOven_Burn_Directory & OverlayForm) OverlayContent = StrDup(LengthofOverlay, "x")...
53
5292
by: noahmd | last post by:
Okay, once-upon-a-time I tried to start programming by learning C. At the time I was younger and didn't really understand all that C had to offer. I eventually moved over to Microsoft's Visual Basic. It was nice to be able to design a visual application with no effort (too bad I didn't really learn the ins and outs of programming) Long...
131
9184
by: Lawrence D'Oliveiro | last post by:
The "escape" function in the "cgi" module escapes characters with special meanings in HTML. The ones that need escaping are '<', '&' and '"'. However, cgi.escape only escapes the quote character if you pass a second argument of True (the default is False): 'the "quick" &amp; &lt;brown&gt; fox' 'the &quot;quick&quot; &amp; &lt;brown&gt; fox' This seems to me to be...
2
3299
by: | last post by:
I mainly work on OS X, but thought I'd experiment with some Python code on XP. The problem is I can't seem to get these things to work at all. First of all, I'd like to use Greek letters in the command prompt window, so I was going to use unicode to do this. But in the command prompt, the unicode characters are displaying as strange...
34
5310
by: Alexnb | last post by:
Gerhard Häring wrote: No, it didn't work, but it gave me some interesting feedback when I ran it in the shell. Heres what it told me: Traceback (most recent call last): File "<pyshell#10>", line 1, in <module> os.startfile("C:\Documents and Settings\Alex\My Documents\My
0
7632
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
7841
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. ...
0
8066
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
7920
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...
1
5458
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...
0
5175
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
3605
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
1169
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
877
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.