473,748 Members | 2,551 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1317
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*****@somewh ere.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*******@gmai l.comwrote in message
news:11******** ************@h4 8g2000cwc.googl egroups.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*******@gmai l.comwrote in message
news:11******** ************@h4 8g2000cwc.googl egroups.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

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

Similar topics

22
2565
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 the video from a DVD but not the audio. He had been searching for an answer for days on support.microsoft.com but found none. I suggested Google and Gateway. Gateway had nothing, but sure enough, search for *XP DVD no sound* on Google and...
119
4618
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, http://www.alistapart.com/articles/betterliving/ I read on http://msdn.microsoft.com/netframework/default.aspx?pull=/library/en-us/dnnetdep/html/netfxcompat.asp It said they changed stuff like this
12
1659
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 saveYourWorkReminder() { alert("It's been 5 minutes. Please save your work. Web browsers are buggy and crash often. Protect yourself!"); }
1
5527
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 table of the MS-SQL Database, "TestODBC". I wanted to use StoredProcedure1 as the bound recordsource for a new form Form1. But I
5
2799
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 ACC2K2 (SP-2) -------------- ---------------------------
9
13296
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 work like buffered? the program is below
1
1405
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
2390
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 any of the response.write lines from inside the sub. ******************************************* <%@ Application Language="VB" %> <script runat="server">
15
4052
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 CALLING FORM! This is very bad for me, because in my application, Form1 responds to an ENTER keypress by calling Form2. If the user closes Form2 via an ENTER, then Form1 just reopens it again, kind of trapping the user in Form2 (they can still close...
6
4896
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 the html page controls the form fields that are required. It doesn't function like it's supposed to and I can leave all the fields blank and it still submits the form. Also I can't get it to transfer the file in the upload section. The file name...
0
8994
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
8831
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
9250
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6796
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
6076
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
4878
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3315
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
2
2787
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2215
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.