473,406 Members | 2,894 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,406 software developers and data experts.

html output lines

given that php
echo '<div>';
echo 'whatever';
echo '</div>';
echo '<div>';
echo 'whatever';
echo '</div>';
echo '<div>';
echo 'whatever';
echo '</div>';
echo '<div>';
echo 'whatever';
echo '</div>';
the output html is

<div>whatever</div><div>whatever</div><div>whatever</div><div>whatever</div>

whereas I would like to have as output the following (It's better in
order to read and understand the html code)

<div>
whatever
</div>
<div>
whatever
</div>
<div>
whatever
</div>
<div>
whatever
</div>

How should I do ?

regards - jm

Mar 24 '06 #1
9 1635
echo '<div>\n';

--gary

Mar 24 '06 #2

fiziwig wrote:
echo '<div>\n';


It actually prints \n in the browser, which is what I don't want. I
just need to add carriage retruns in the html source, not the rendered
page

regards - jm

Mar 24 '06 #3
ED
"fiziwig" <fi*****@yahoo.com> wrote in message
news:11*********************@t31g2000cwb.googlegro ups.com...
echo '<div>\n';

--gary


erm, shouldn't that be:
echo "<div>\n";
(note: double quotes not single)

ED
Mar 24 '06 #4
My bad. Double quotes are necessary to that php actually interprets the
contents of the quotes instead of just echoing it as is.

--gary

Mar 24 '06 #5
ED wrote:
"fiziwig" <fi*****@yahoo.com> wrote in message
news:11*********************@t31g2000cwb.googlegro ups.com...
echo '<div>\n';

--gary


erm, shouldn't that be:
echo "<div>\n";
(note: double quotes not single)


or you could define the end of line string in a constant for easier
modification down the road...

<?php
define('CRLF',"\r\n");

echo '<div>',CRLF;
....
?>

--
Justin Koivisto, ZCE - ju****@koivi.com
http://koivi.com
Mar 24 '06 #6
ED
true, but you have to type 4 characters every line instead of 2 that way ;-)

"Justin Koivisto" <ju****@koivi.com> wrote in message
news:8J********************@onvoy.com...
ED wrote:
"fiziwig" <fi*****@yahoo.com> wrote in message
news:11*********************@t31g2000cwb.googlegro ups.com...
echo '<div>\n';

--gary


erm, shouldn't that be:
echo "<div>\n";
(note: double quotes not single)


or you could define the end of line string in a constant for easier
modification down the road...

<?php
define('CRLF',"\r\n");

echo '<div>',CRLF;
...
?>

--
Justin Koivisto, ZCE - ju****@koivi.com
http://koivi.com

Mar 25 '06 #7
Justin Koivisto:
or you could define the end of line string in a constant for easier
modification down the road...
Good idea I reckon...
define('CRLF',"\r\n");


That's circular. Since '\r\n' in double quotes means a CRLF pair,
define()-ing 'CRLF' as such doesn't better position you. What's worse,
if the value was to change to one or the other (i.e., to either CR or
LF, or indeed to something else) then the label 'CRLF' becomes a
misnomer.

What is useful to define(), I think, and I believe this was your
point, is not a label representing a particular 'end of line string'
but rather the end-of-line itself. (There is a predefined constant,
namely 'PHP_EOL', that would seem to stand for end-of-line, but I can't
find any documentation.)

--
Jock

Mar 25 '06 #8

Justin Koivisto wrote:
ED wrote:
"fiziwig" <fi*****@yahoo.com> wrote in message
news:11*********************@t31g2000cwb.googlegro ups.com...
echo '<div>\n';

--gary

erm, shouldn't that be:
echo "<div>\n";
(note: double quotes not single)


or you could define the end of line string in a constant for easier
modification down the road...


That's what I did already, thinking in the same scenario, using a var
though:
$L_end = "\n";
<?php
define('CRLF',"\r\n");

echo '<div>',CRLF;


It is possible to join two strings with ',' or it was just a typo ???

regards - jm

Mar 25 '06 #9
d
"julian_m" <ju***********@gmail.com> wrote in message
news:11**********************@i40g2000cwc.googlegr oups.com...

Justin Koivisto wrote:
ED wrote:
> "fiziwig" <fi*****@yahoo.com> wrote in message
> news:11*********************@t31g2000cwb.googlegro ups.com...
>> echo '<div>\n';
>>
>> --gary
>>
>
> erm, shouldn't that be:
> echo "<div>\n";
> (note: double quotes not single)
or you could define the end of line string in a constant for easier
modification down the road...


That's what I did already, thinking in the same scenario, using a var
though:
$L_end = "\n";
<?php
define('CRLF',"\r\n");

echo '<div>',CRLF;


It is possible to join two strings with ',' or it was just a typo ???


That's not joining strings but passing multiple strings to echo, which is
actually a language construct (and not a function), and as such can handle
such strangeness.
regards - jm

Mar 27 '06 #10

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

Similar topics

10
by: Alex Hopson | last post by:
I'm trying to read an html file from my local server into a string, I'm using the following code: $attfile = $attachment; //create filenames $file_name = basename ($attfile); $lines =...
0
by: Carlos Ribeiro | last post by:
Hello all, While studying some of the templating systems available for Python, I've come up with an idea to implement templates using decorators. The following code snippet runs in Python 2.3; a...
0
by: John M. Lembo | last post by:
I am using Perl to parse a text file and output to another file. The text file has data on Unix virtual memory (vmstat) and I want to delete lines that I don't want and output lines that I want to...
5
by: Jay Chan | last post by:
I am trying to use a command line program to run a stored procedure that generates output in a comma-delimitted format. Somehow, ISQL or OSQL always wrap the lines at 256 characters. I believe this...
3
by: Spacy | last post by:
Am creating a HTML Report in asp.net. To save this report to excel on client-side, i write this code: Response.ContentType = "application/vnd.ms-excel" Response.AddHeader("content-disposition",...
2
by: Tony Gahlinger | last post by:
I'm learning/experimenting with some simple JS/html markup, running an apache daemon and mozilla firefox browser in RH 9. Let's say I run the following markup with one or more of lines 6-10...
8
by: Lawrence Oluyede | last post by:
Is there a way to treat html tags like simple text? I explain myself, if I have a bunch of xml like <content type="application/xhtml+xml" xml:base="http://loluyede.blogspot.com" xml:lang="en-US"...
4
by: DKode | last post by:
I have developed a custom server control that displays a login page that authenticates against AD. The server control works fine, but now I am trying to figure out the best way to output custom...
13
by: DH | last post by:
Hi, I'm trying to strip the html and other useless junk from a html page.. Id like to create something like an automated text editor, where it takes the keywords from a txt file and removes them...
10
by: happyse27 | last post by:
Hi All, I got this apache errors(see section A1 and A2 below) when I used a html(see section b below) to activate acctman.pl(see section c below). Section D below is part of the configuration...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
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,...
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
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,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
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...
0
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...

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.