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 3 1489 sc****@gmail.com 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("{$newtext}\n"); (I prefer
using curly brackets into double-quoted strings)
Regards,
--
Guillaume sc****@gmail.com 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.
Thank you all very much.
Yep I was testing through the browser, your suggetions worked.
Thanks again. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
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 %%...
|
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>
...
|
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,...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
by: af34tf |
last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
| |