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

trouble with echo <br />

I'm an extreme newbie, and have been nosing around the PHP.Net site for a
few days. Only, the search function returns alot of information that's not
truly relevant due to Coding samples at the bottom of the pages.

What I'm trying to determine is :

Which is better for printing info to a page based on dynamic variables?
IE - if I have a boolean = True, should I use PrintF, print, echo to spit
out the info?

Also, when I use either, and have a <br /> in the statement, it puts <br>
instead, and I can't for the life of me get it to put /> there at the end.

And one more thing (begins a rambling rant o questions), the syntax for
boolean use (basic format?)

I used
$good = TRUE

if($good == TRUE) { echo "blah <br />" } and it doesn't seem to trigger.

If I use = TRUE, it triggers, but i think that's wrong for some reason.

-Khai
Dec 2 '05 #1
14 16449
Echo is a construct, print is a function. I think speed wise they
should both be the same.

Try

$good = TRUE;

if($good == TRUE) { echo "blah <br />"; }

You forgot those semi colons. Not sure why it isn't printing out the
/>.

This

$good = TRUE;

if($good = TRUE) { echo "blah <br />"; }

Will always evaluate to try because instead of doing a comparison you
are doing an assignment.

Dec 2 '05 #2
Man, you were so right. AS soon as I saw the first Try $good = TRUE; it
dawned on me that I never set the $good to anything except FALSE. So when
it was testing for $good == TRUE it was coming up false, because $good was
never ever set to true, it was just an empty var. *smacks forhead*.

However, I changed my echo setup and went with escaping to HTML, IE:

<?php if ($good = TRUE) { ?>
blah blah <br />
<?php }; ?>

THat seems to work better, but still having issues getting the <br />
instead of the <br> it keeps punching out. Perhaps it's just in cache and I
need to clear it.

Thanks =)

-khai
"Sean" <or**********@gmail.com> wrote in message
news:11**********************@g49g2000cwa.googlegr oups.com...
Echo is a construct, print is a function. I think speed wise they
should both be the same.

Try

$good = TRUE;

if($good == TRUE) { echo "blah <br />"; }

You forgot those semi colons. Not sure why it isn't printing out the
/>.

This

$good = TRUE;

if($good = TRUE) { echo "blah <br />"; }

Will always evaluate to try because instead of doing a comparison you
are doing an assignment.

Dec 2 '05 #3
In our last episode,
<xN******************************@comcast.com>,
the lovely and talented Khai
broadcast on comp.lang.php:
THat seems to work better, but still having issues getting the <br />
instead of the <br> it keeps punching out. Perhaps it's just in cache and I
need to clear it. Thanks =)


Are you running your output through lint such as tidy?
If it (the lint) doesn't know you are trying to write xhtml, it
will "correct" it to html. Be sure your doctype declares xhtml,
too.

--
Lars Eighner us****@larseighner.com http://www.larseighner.com/
Love: The warm feeling you get towards someone who meets your neurotic needs.
Dec 2 '05 #4
I think u should it without that space so u should try it <br/> only
not <br />

Dec 4 '05 #5
XIII wrote:
I think u should it without that space so u should try it <br/> only
not <br />

Except if it is XHTML the space is required, now if the original file is
HTML no XHTML it should be '<br>' with no '/'

--
Take care,

Jonathan
-------------------
LITTLE WORKS STUDIO
http://www.LittleWorksStudio.com
Dec 4 '05 #6
Ok - it seems that PHP has a Tidy library that tries to validate/repair
html. Since <br /> is expected to have a <br>, it's replacing it with a
<br>.

Even if it's written outside <?php ?>, or echo from inside, it still puts
<br> instead of just <br />.

Is there a way around this, rather than writing <br> <br /> every time I
want a break?

Thanks,

Khai
"Lars Eighner" <us****@larseighner.com> wrote in message
news:sl********************@goodwill.io.com...
In our last episode,
<xN******************************@comcast.com>,
the lovely and talented Khai
broadcast on comp.lang.php:
THat seems to work better, but still having issues getting the <br />
instead of the <br> it keeps punching out. Perhaps it's just in cache and I need to clear it.
Thanks =)


Are you running your output through lint such as tidy?
If it (the lint) doesn't know you are trying to write xhtml, it
will "correct" it to html. Be sure your doctype declares xhtml,
too.

--
Lars Eighner us****@larseighner.com

http://www.larseighner.com/ Love: The warm feeling you get towards someone who meets your neurotic

needs.
Dec 5 '05 #7
In our last episode,
<qL******************************@comcast.com>,
the lovely and talented Khai
broadcast on comp.lang.php:
Ok - it seems that PHP has a Tidy library that tries to validate/repair
html. Since <br /> is expected to have a <br>, it's replacing it with a
<br>.
There are tidy functions in php, but if you are not invoking
them, I don't see how they would affect things. I suspect that
tidy is being run externally on your output. Before looking
any deeper in php, be sure your doctype declares xhtml and try
using a .tidyrc with an xhtml doctype option.
Even if it's written outside <?php ?>, or echo from inside, it still puts
<br> instead of just <br />.
Just echoing or printing tags should not do anything with php's
tidy functions, which seem to be some kind of object-oriented
crap.
Is there a way around this, rather than writing <br> <br /> every time I
want a break?


See if this happens in documents generated by php cli. I bet it
doesn't. If it doesn't, there is some kind of post processing
going on. If it is nice, it should get the right answer if you
provide the right doctype and/or .tidyrc .

--
Lars Eighner us****@larseighner.com http://www.larseighner.com/
Good Morning, Carnivore! - Anthrax botulin nuclear flight mail Akbar reservoir
Ramadan letter activate bridge Abdul safehouse virgins money detonators Allah
smallpox Glaspie Springfield agent airport dispersal facility counterfeit
Dec 5 '05 #8
"Khai" <middae*nospam*@*nO_Spam*hotmail.com> wrote:

Ok - it seems that PHP has a Tidy library that tries to validate/repair
html. Since <br /> is expected to have a <br>,


No, it's not. The close of a matching pair has the / at the beginning:
<p> </p>
The / at the end specifically means "this is a standalone tag that does not
have a closing mate". Thus, <br /> is quite correct.
--
- Tim Roberts, ti**@probo.com
Providenza & Boekelheide, Inc.
Dec 6 '05 #9
I have tried it both ways, and it seems it spits out <br>'s only. I'm at my
wits end. *sighs*

-khai

if anyone takes pitty, i'll be happy to post the source or email it.

-khaiv2

"Jonathan N. Little" <lw*****@centralva.net> wrote in message
news:43***********************@news.centralva.net. ..
XIII wrote:
I think u should it without that space so u should try it <br/> only
not <br />

Except if it is XHTML the space is required, now if the original file is
HTML no XHTML it should be '<br>' with no '/'

--
Take care,

Jonathan
-------------------
LITTLE WORKS STUDIO
http://www.LittleWorksStudio.com

Dec 6 '05 #10
Khai wrote:
Man, you were so right. AS soon as I saw the first Try $good = TRUE; it
dawned on me that I never set the $good to anything except FALSE. So when
it was testing for $good == TRUE it was coming up false, because $good was
never ever set to true, it was just an empty var. *smacks forhead*.

However, I changed my echo setup and went with escaping to HTML, IE:

<?php if ($good = TRUE) { ?>
blah blah <br />
<?php }; ?>

THat seems to work better, but still having issues getting the <br />
instead of the <br> it keeps punching out. Perhaps it's just in cache and I
need to clear it.


How do you know it is producing <br>? Where are you looking at it?
It looks as if something along the way is rewriting your XHTML as HTML.

Colin
Dec 7 '05 #11

"Colin Fine" <ne**@kindness.demon.co.uk> wrote in message
news:dn*******************@news.demon.co.uk...
How do you know it is producing <br>? Where are you looking at it?
It looks as if something along the way is rewriting your XHTML as HTML.

Colin


I'm looking at the output in the browser (FireFox), and then view source.

My code is simply an <?php IF ( ) { ?> html code <br /> <?php } ?> to
generate an output. I've also tried echo, and print_f and when I look at the
output in a browser, via view source, it changes the <br /> to a <br>

*screaming and losing hair*

-khai
Dec 7 '05 #12
In our last episode,
<We********************@comcast.com>,
the lovely and talented Khai
broadcast on comp.lang.php:

"Colin Fine" <ne**@kindness.demon.co.uk> wrote in message
news:dn*******************@news.demon.co.uk...
How do you know it is producing <br>? Where are you looking at it?
It looks as if something along the way is rewriting your XHTML as HTML.

Colin
I'm looking at the output in the browser (FireFox), and then view source. My code is simply an <?php IF ( ) { ?> html code <br /> <?php } ?> to
generate an output. I've also tried echo, and print_f and when I look at the
output in a browser, via view source, it changes the <br /> to a <br> *screaming and losing hair*


I don't understand why that outputs anything.

() should never be true, so if() should never execute whatever
is in the brackets.

if(1) outputs

html code <br />

but that isn't an html document, and in any event
my firefox doesn't change the <br /> to <br>
--
Lars Eighner us****@larseighner.com http://www.larseighner.com/
"We have no opinion on your Arab - Arab conflicts, such as your dispute with
Kuwait." -- Bush's Ambassador April Glaspie, giving Saddam Hussein
the greenlight to invade Kuwait.
Dec 7 '05 #13
Khai wrote:
"Colin Fine" <ne**@kindness.demon.co.uk> wrote in message
news:dn*******************@news.demon.co.uk...
How do you know it is producing <br>? Where are you looking at it?
It looks as if something along the way is rewriting your XHTML as HTML.

Colin

I'm looking at the output in the browser (FireFox), and then view source.

My code is simply an <?php IF ( ) { ?> html code <br /> <?php } ?> to
generate an output. I've also tried echo, and print_f and when I look at the
output in a browser, via view source, it changes the <br /> to a <br>

*screaming and losing hair*

-khai

That's my point. By that time your output has gone through your server
and your browser. Have you looked at it with a different browser? (I'm
not aware that Firefox or any other browser alters the source it
receives when you ask to see it, but it's not impossible).

Is there a way you can look at it as it leaves your server (I admit I
can't quite see how).

Colin
Dec 8 '05 #14
Lars Eighner wrote:
In our last episode,
<We********************@comcast.com>,
the lovely and talented Khai
broadcast on comp.lang.php:
"Colin Fine" <ne**@kindness.demon.co.uk> wrote in message
news:dn*******************@news.demon.co.uk...
How do you know it is producing <br>? Where are you looking at it?
It looks as if something along the way is rewriting your XHTML as HTML.

Colin


I'm looking at the output in the browser (FireFox), and then view source.


My code is simply an <?php IF ( ) { ?> html code <br /> <?php } ?> to
generate an output. I've also tried echo, and print_f and when I look at the
output in a browser, via view source, it changes the <br /> to a <br>


*screaming and losing hair*

I don't understand why that outputs anything.

() should never be true, so if() should never execute whatever
is in the brackets.

if(1) outputs

html code <br />

but that isn't an html document, and in any event
my firefox doesn't change the <br /> to <br>

I think you are being excessively literal, Lars. The word 'an' implies
that the code he just quoted is a schema, not the whole of the code.

Colin
Dec 8 '05 #15

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

Similar topics

4
by: fis | last post by:
Hi all, I've problem because there are needed break lines in my texts on the web site but i can't do it :( My pipeline looks like: XMS -> I18N -> XSLT -> HTML I have lot of texts in my...
6
by: Lasse | last post by:
I have done this simple function, it seems to work as intended, to solve a problem i have had for a while. I couldnt find any sample around that was working for me. I would like to test it with...
7
by: noor.rahman | last post by:
I have an XML file that stores data from an HTML form. I use XSL to display the data in HTML format. The data may have newline characters. However, XSL is not displaying the newlines properly in...
7
by: Rocky Moore | last post by:
I have a web site called HintsAndTips.com. On this site people post tips using a very simply webform with a multi line TextBox for inputing the tip text. This text is encode to HTML so that no...
5
by: SteveB | last post by:
How can I write a break on Web Form using C#?
2
by: Winshent | last post by:
I have a multi line text in an admin page on my cms. I am trying to capture carriage returns as and replace them with <p></p> bfore the string gets written to the database. I have tried all...
1
by: Winshent | last post by:
I have a multi line text in an admin page on my cms. I am trying to capture carriage returns as and replace them with <p></p> bfore the string gets written to the database. I have tried all...
7
by: Nathan Sokalski | last post by:
Something that I recently noticed in IE6 (I don't know whether it is true for other browsers or versions of IE) is that it renders <br/and <br></br> differently. With the <br/version, which is what...
2
by: kaotik78 | last post by:
I've racked my head on this all day long. I've been using php for 3 days now and this is the first hang up I've had and it's driving me nuts, but I can't pull myself away from trying to fix the...
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: 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:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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.