473,387 Members | 1,455 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,387 software developers and data experts.

New Lines (\n) and Single Quotes

Is there anyway to make new lines in single quotes?

Thanks,

Jon Smith
Jul 17 '05 #1
5 4794
On Tue, 03 Feb 2004 23:28:35 GMT, "Jon Smith" <js****@NOSPAM.earthlink.net>
wrote:
Is there anyway to make new lines in single quotes?


$answer = 'yes,
there is.';

--
Andy Hassall <an**@andyh.co.uk> / Space: disk usage analysis tool
<http://www.andyh.co.uk> / <http://www.andyhsoftware.co.uk/space>
Jul 17 '05 #2
Jon Smith wrote:
Is there anyway to make new lines in single quotes?

Thanks,

Jon Smith


No, not that I'm aware of :)

you can try:

<?php
define('LF', "\n"); // or 'NL' or 'NewLine' or 'LineFeed' or ...

echo 'first line', LF, 'second line';
// avoids (lol)
// echo "first line\nsecond line";
// or
// echo 'first line', "\n", 'second line';
?>
--
--= my mail box only accepts =--
--= Content-Type: text/plain =--
--= Size below 10001 bytes =--
Jul 17 '05 #3
Andy Hassall wrote:
On Tue, 03 Feb 2004 23:28:35 GMT, "Jon Smith" <js****@NOSPAM.earthlink.net>
wrote:
Is there anyway to make new lines in single quotes?


$answer = 'yes,
there is.';


Ah! I felt like I was missing something :-)
--
--= my mail box only accepts =--
--= Content-Type: text/plain =--
--= Size below 10001 bytes =--
Jul 17 '05 #4
On Tue, 03 Feb 2004 23:28:35 GMT, "Jon Smith"
<js****@NOSPAM.earthlink.net> wrote:
Is there anyway to make new lines in single quotes?

Thanks,

Jon Smith


You can break single-quoted strings (and double-quoted, for that
matter) over multiple lines.

Ex:

<?php

$string =
'This is
a string
with newlines!';

?>

But if you mean using the literal character(s) \n, then you'd have to
do it like:

<?php

$string = 'This is' . "\n" . 'a string' . "\n" . 'with newlines!';

?>

Which one is easier to read for you? ;)

Jul 17 '05 #5
Thanks for the help, I thought that was the only way...

JS

"auntie social" <no@thanks.sucker> wrote in message
news:g5********************************@4ax.com...
| On Tue, 03 Feb 2004 23:28:35 GMT, "Jon Smith"
| <js****@NOSPAM.earthlink.net> wrote:
|
| >Is there anyway to make new lines in single quotes?
| >
| >Thanks,
| >
| >Jon Smith
| >
|
| You can break single-quoted strings (and double-quoted, for that
| matter) over multiple lines.
|
| Ex:
|
| <?php
|
| $string =
| 'This is
| a string
| with newlines!';
|
| ?>
|
| But if you mean using the literal character(s) \n, then you'd have to
| do it like:
|
| <?php
|
| $string = 'This is' . "\n" . 'a string' . "\n" . 'with newlines!';
|
| ?>
|
| Which one is easier to read for you? ;)
|
Jul 17 '05 #6

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

Similar topics

5
by: sinister | last post by:
The examples in the online manual all seem to use double quotes, e.g. at http://us3.php.net/preg_replace Why? (The behavior is different with single quotes, and presumably simpler to...
11
by: Jakanapes | last post by:
Hi all, I'm looking for a way to scan a block of text and replace all the double quotes (") with single quotes ('). I'm using PHP to pull text out of a mySQL table and then feed the text into...
4
by: sankofa | last post by:
hi, i can't seem to be able to escape my single quote properly... is it even possible in javascript? this is a portion of my code.. var DLEWIS="Pastor Lewis"; .... Sermon is a yser-defined...
5
by: Joel | last post by:
Hi, I incorporated a function in my code that whenever I use a string variable in an sql statement if the string contains a single quote it will encase it in double quotes else single quotes. ...
1
by: Robizzle | last post by:
I'm writting a script that produces html source code from form input. My problem is that I want to format my html source with new lines and tabs. So, I have a string that holds all the contents...
4
by: Greg | last post by:
I keep getting an error when I have a tick mark in a text value that I am searching for in my XPath Query. Example: <Authors> <Author LastName="O'Donnel"> <Author LastName="Smith">...
3
by: Jason | last post by:
I have several tables with quite a few fields and I'm getting errors when trying to insert records with single quotes in the data like: name = John O'Henry or a city name of O'Fallen So I went...
4
by: chopin | last post by:
I am using Visual Basic for Applications to convert a number to the same number of single quotes. For example, if the number is 6, then I need 6 single quotes in succession. The logic is easy: ...
2
by: Reporter | last post by:
I got the following example from http://www.evolt.org/article/User_Friendly_Forms_in_PHP/20/60144/index.html : echo '<tr><td>First name:</td><td><input type="text" name="first_name"...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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...
0
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...

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.