473,320 Members | 2,110 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Can't get \n to work.

sk
According to zend.com

Double and single quoted strings are handled differently by PHP. Double
quoted strings are interpreted while single quoted strings are treated
exactly as written. For example:

$foo = 2;
echo "foo is $foo"; // this prints: foo is 2
echo 'foo is $foo'; // this prints: foo is $foo
echo "foo is $foo\n"; // this prints: foo is 2 (with a new-line)
echo 'foo is $foo\n'; // this prints: foo is $foo\n

I can not get this to work.

Oct 4 '06 #1
11 1289
Can you paste the code that isn't working? The zend.com tutorial is
exactly right.

sk wrote:
According to zend.com

Double and single quoted strings are handled differently by PHP. Double
quoted strings are interpreted while single quoted strings are treated
exactly as written. For example:

$foo = 2;
echo "foo is $foo"; // this prints: foo is 2
echo 'foo is $foo'; // this prints: foo is $foo
echo "foo is $foo\n"; // this prints: foo is 2 (with a new-line)
echo 'foo is $foo\n'; // this prints: foo is $foo\n

I can not get this to work.
Oct 5 '06 #2
sk wrote:
According to zend.com

Double and single quoted strings are handled differently by PHP.
Double quoted strings are interpreted while single quoted strings are
treated exactly as written. For example:

$foo = 2;
echo "foo is $foo"; // this prints: foo is 2
echo 'foo is $foo'; // this prints: foo is $foo
echo "foo is $foo\n"; // this prints: foo is 2 (with a new-line)
echo 'foo is $foo\n'; // this prints: foo is $foo\n

I can not get this to work.
In what way can you not get it to work?

If you are outputting HTML and viewing it in a web browser, it pays to
remember that newline breaks are *not* rendered. To render a line break
in a web browser you need <br / If you view the source of the page
you'll see those \n line breaks there but not in the normal browser
window.

--
Chris Hope | www.electrictoolbox.com | www.linuxcdmall.com
Oct 5 '06 #3
Hmm sk <so*****@somewhere.orgwrote:
I can not get this to work.
Why? There is no error.
--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Ikciu | gg: 718845 | yahoo: ikciu_irsa | www: www.e-irsa.pl

2be || !2be $this =mysql_query();
Oct 5 '06 #4
sk wrote:
echo "foo is $foo\n"; // this prints: foo is 2 (with a new-line)
...
I can not get this to work.
I've had the same problem.
This is a bit clunky but always works for me:

$cr = '
';

echo "foo is $foo" . $cr;
Oct 5 '06 #5
<pe*******@gmail.comwrote in message
news:11********************@h48g2000cwc.googlegrou ps.com...
Can you paste the code that isn't working? The zend.com tutorial is
exactly right.

sk wrote:
According to zend.com

Double and single quoted strings are handled differently by PHP. Double
quoted strings are interpreted while single quoted strings are treated
exactly as written. For example:

$foo = 2;
echo "foo is $foo"; // this prints: foo is 2
echo 'foo is $foo'; // this prints: foo is $foo
echo "foo is $foo\n"; // this prints: foo is 2 (with a new-line)
echo 'foo is $foo\n'; // this prints: foo is $foo\n

I can not get this to work.
Sometimes you must add \r to it like so:

echo "foo is $foo\n\r";

Norm
Oct 6 '06 #6
sk
The following line is the output from the below.

foo is 2foo is $foofoo is 2 foo is $foo\n

$foo = 2;
echo "foo is $foo"; // this prints: foo is 2
echo 'foo is $foo'; // this prints: foo is $foo
echo "foo is $foo\n"; // this prints: foo is 2 (with a new-line)
echo 'foo is $foo\n'; // this prints: foo is $foo\n

As you can see, no new-line.

pe*******@gmail.com wrote:
Can you paste the code that isn't working? The zend.com tutorial is
exactly right.

sk wrote:
>>According to zend.com

Double and single quoted strings are handled differently by PHP. Double
quoted strings are interpreted while single quoted strings are treated
exactly as written. For example:

$foo = 2;
echo "foo is $foo"; // this prints: foo is 2
echo 'foo is $foo'; // this prints: foo is $foo
echo "foo is $foo\n"; // this prints: foo is 2 (with a new-line)
echo 'foo is $foo\n'; // this prints: foo is $foo\n

I can not get this to work.

Oct 6 '06 #7
sk
tried following with same results.... no new line

$foo = 2;
echo "foo is $foo"; // this prints: foo is 2
echo 'foo is $foo'; // this prints: foo is $foo
echo "foo is $foo\n\r"; // this prints: foo is 2 (with a new-line)
echo 'foo is $foo\n'; // this prints: foo is $foo\n

Norman Peelman wrote:
<pe*******@gmail.comwrote in message
news:11********************@h48g2000cwc.googlegrou ps.com...
>>Can you paste the code that isn't working? The zend.com tutorial is
exactly right.

sk wrote:
>>>According to zend.com

Double and single quoted strings are handled differently by PHP. Double
quoted strings are interpreted while single quoted strings are treated
exactly as written. For example:

$foo = 2;
echo "foo is $foo"; // this prints: foo is 2
echo 'foo is $foo'; // this prints: foo is $foo
echo "foo is $foo\n"; // this prints: foo is 2 (with a new-line)
echo 'foo is $foo\n'; // this prints: foo is $foo\n

I can not get this to work.

Sometimes you must add \r to it like so:

echo "foo is $foo\n\r";

Norm

Oct 6 '06 #8
sk
That explains it. Thanks much. Can now quit spinning my wheels.

Thanks to all.

Chris Hope wrote:
sk wrote:

>>According to zend.com

Double and single quoted strings are handled differently by PHP.
Double quoted strings are interpreted while single quoted strings are
treated exactly as written. For example:

$foo = 2;
echo "foo is $foo"; // this prints: foo is 2
echo 'foo is $foo'; // this prints: foo is $foo
echo "foo is $foo\n"; // this prints: foo is 2 (with a new-line)
echo 'foo is $foo\n'; // this prints: foo is $foo\n

I can not get this to work.


In what way can you not get it to work?

If you are outputting HTML and viewing it in a web browser, it pays to
remember that newline breaks are *not* rendered. To render a line break
in a web browser you need <br / If you view the source of the page
you'll see those \n line breaks there but not in the normal browser
window.
Oct 6 '06 #9
sk wrote:
According to zend.com

Double and single quoted strings are handled differently by PHP. Double
quoted strings are interpreted while single quoted strings are treated
exactly as written. For example:

$foo = 2;
echo "foo is $foo"; // this prints: foo is 2
echo 'foo is $foo'; // this prints: foo is $foo
echo "foo is $foo\n"; // this prints: foo is 2 (with a new-line)
echo 'foo is $foo\n'; // this prints: foo is $foo\n

I can not get this to work.
And we're all supposed to guess in what way it doesn't work?

I'm sorry if this sounds crabby, sk, but it is a bugbear of mine at work
as well as here.

'I can't get this to work' is as much use as 'My car won't go'.

PLEASE, if you ask for assistance, give people the information they need
to render assistance: tell them
- what you did
- what happened (including what you saw)
- what system/context you were in
- what you expected, if it is not obvious.

</lecture>

Colin
Oct 6 '06 #10
sk
Seems like you are only one who had problem understanding only logical
'can't get this to work'. However, No new-line!
Colin Fine wrote:
sk wrote:
>According to zend.com

Double and single quoted strings are handled differently by PHP.
Double quoted strings are interpreted while single quoted strings are
treated exactly as written. For example:

$foo = 2;
echo "foo is $foo"; // this prints: foo is 2
echo 'foo is $foo'; // this prints: foo is $foo
echo "foo is $foo\n"; // this prints: foo is 2 (with a new-line)
echo 'foo is $foo\n'; // this prints: foo is $foo\n

I can not get this to work.

And we're all supposed to guess in what way it doesn't work?

I'm sorry if this sounds crabby, sk, but it is a bugbear of mine at work
as well as here.

'I can't get this to work' is as much use as 'My car won't go'.

PLEASE, if you ask for assistance, give people the information they need
to render assistance: tell them
- what you did
- what happened (including what you saw)
- what system/context you were in
- what you expected, if it is not obvious.

</lecture>

Colin
Oct 6 '06 #11
sk wrote:
Seems like you are only one who had problem understanding only logical
'can't get this to work'. However, No new-line!
Oh really?

petersrpc said:
"Can you paste the code that isn't working? The zend.com tutorial is
exactly right."

Norman Peelman and Gary Hassler both did guess what problem your were
seeing, but since they didn't know you were talking about HTML, their
suggestions were irrelevant.

Chris Hope asked:
"Can you paste the code that isn't working? The zend.com tutorial is
exactly right."
but did then guess the problem and gave you the solution.

ikciu said:
"Why? There is no error."

So of the six people who replied to you, three of us asked for more
information, one said there was no problem (which there isn't, in the
code) and three guessed what you might mean. Of those three, two guessed
wrong.

So actually, far from my being 'the only one who had a problem
understanding', Chris Hope was the only one out of six who guessed what
the problem was! And he asked for more information.

Far from being "the only logical 'can't get this to work'", your missing
new-line is nothing whatever to do with your PHP code!

Colin
Oct 7 '06 #12

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

Similar topics

22
by: The Road To Utopia | last post by:
Here's one for the trolls...a common jibe from them is setting up audio/video hardware under linux. Ok, true story: at work today, someone asked me if I could tell him why his XP Home would play...
119
by: rhat | last post by:
I heard that beta 2 now makes ASP.NET xhtml compliant. Can anyone shed some light on what this will change and it will break stuff as converting HTML to XHTML pages DO break things. see,...
12
by: lkrubner | last post by:
Is there any reason why this code wouldn't prompt someone to save their work every 5 minutes? It doesn't seem to be working. This code shows up in the HEAD of an HTML document. function...
1
by: Lyle Fairfield | last post by:
I created a new MS-SQL Database, "TestODBC". I made Table1 and StoredProcedure1. I made an ODBC DSN for that MS-SQL Database. I created a new AccessXP mdb, "TestODBC". I linked to the...
5
by: MGFoster | last post by:
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 I've converted an ACC97 .mdb file to an ACC2K2 .adp. A report that worked in ACC97 doesn't work in ACC2K2. Report setup: ACC97 ...
9
by: kernelxu | last post by:
hi, everyone. now, I'am confused on such a problem: function setbuf(stdin, NULL) or setvbuf(stdin, NULL, _IONBF, 0) can set the stadard input stream unbuffered. however, why does my program...
1
by: Larry | last post by:
These is a interface " IPerson" and a class "SoftwareDeveloper" support the interface; public __gc __interface IPerson { void Eat(); void Sleep(; void Work();
9
by: tshad | last post by:
I have an example I copied from "programming asp.net" (o'reilly) and can't seem to get the Sub (writefile) to execute. It displays all the response.write lines that are called directly, but not...
15
by: Adam J. Schaff | last post by:
I have noticed that if a user closes a form via pressing return (either while the OK button has focus or if AcceptButton is set to OK for the form) then the "ENTER" keypress event fires ON THE...
6
by: scottyman | last post by:
I can't make this script work properly. I've gone as far as I can with it and the rest is out of my ability. I can do some html editing but I'm lost in the Java world. The script at the bottom of...
0
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...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
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...
1
isladogs
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...
0
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...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
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
0
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...

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.