trouble with echo <br />

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Khai

    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


  • Sean

    #2
    Re: trouble with echo &lt;br /&gt;

    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.

    Comment

    • Khai

      #3
      Re: trouble with echo &lt;br /&gt;

      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" <oreilly.sean@g mail.com> wrote in message
      news:1133549200 .573351.284560@ g49g2000cwa.goo glegroups.com.. .[color=blue]
      > 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.
      >[/color]


      Comment

      • Lars Eighner

        #4
        Re: trouble with echo &lt;br /&gt;

        In our last episode,
        <xNydnQ8yKsyxBA 3enZ2dnUVZ_v-dnZ2d@comcast.c om>,
        the lovely and talented Khai
        broadcast on comp.lang.php:
        [color=blue]
        > 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.[/color]
        [color=blue]
        > Thanks =)[/color]

        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 usenet@larseigh ner.com http://www.larseighner.com/
        Love: The warm feeling you get towards someone who meets your neurotic needs.

        Comment

        • XIII

          #5
          Re: trouble with echo &lt;br /&gt;

          I think u should it without that space so u should try it <br/> only
          not <br />

          Comment

          • Jonathan N. Little

            #6
            Re: trouble with echo &lt;br /&gt;

            XIII wrote:
            [color=blue]
            > I think u should it without that space so u should try it <br/> only
            > not <br />
            >[/color]
            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

            Comment

            • Khai

              #7
              Re: trouble with echo &lt;br /&gt;

              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" <usenet@larseig hner.com> wrote in message
              news:slrndp1bcq .23c9.usenet@go odwill.io.com.. .[color=blue]
              > In our last episode,
              > <xNydnQ8yKsyxBA 3enZ2dnUVZ_v-dnZ2d@comcast.c om>,
              > the lovely and talented Khai
              > broadcast on comp.lang.php:
              >[color=green]
              > > 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[/color][/color]
              and I[color=blue][color=green]
              > > need to clear it.[/color]
              >[color=green]
              > > Thanks =)[/color]
              >
              > 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 usenet@larseigh ner.com[/color]
              http://www.larseighner.com/[color=blue]
              > Love: The warm feeling you get towards someone who meets your neurotic[/color]
              needs.


              Comment

              • Lars Eighner

                #8
                Re: trouble with echo &lt;br /&gt;

                In our last episode,
                <qLmdnbMArce17A nenZ2dnUVZ_tidn Z2d@comcast.com >,
                the lovely and talented Khai
                broadcast on comp.lang.php:
                [color=blue]
                > 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>.[/color]

                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.
                [color=blue]
                > Even if it's written outside <?php ?>, or echo from inside, it still puts
                ><br> instead of just <br />.[/color]

                Just echoing or printing tags should not do anything with php's
                tidy functions, which seem to be some kind of object-oriented
                crap.
                [color=blue]
                > Is there a way around this, rather than writing <br> <br /> every time I
                > want a break?[/color]

                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 usenet@larseigh ner.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

                Comment

                • Tim Roberts

                  #9
                  Re: trouble with echo &lt;br /&gt;

                  "Khai" <middae*nospam* @*nO_Spam*hotma il.com> wrote:[color=blue]
                  >
                  >Ok - it seems that PHP has a Tidy library that tries to validate/repair
                  >html. Since <br /> is expected to have a <br>,[/color]

                  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, timr@probo.com
                  Providenza & Boekelheide, Inc.

                  Comment

                  • Khai

                    #10
                    Re: trouble with echo &lt;br /&gt;

                    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" <lws4art@centra lva.net> wrote in message
                    news:43923ab1$0 $17661$cb0e7fc6 @news.centralva .net...[color=blue]
                    > XIII wrote:
                    >[color=green]
                    > > I think u should it without that space so u should try it <br/> only
                    > > not <br />
                    > >[/color]
                    > 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[/color]


                    Comment

                    • Colin Fine

                      #11
                      Re: trouble with echo &lt;br /&gt;

                      Khai wrote:[color=blue]
                      > 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.[/color]

                      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

                      Comment

                      • Khai

                        #12
                        Re: trouble with echo &lt;br /&gt;


                        "Colin Fine" <news@kindness. demon.co.uk> wrote in message
                        news:dn583g$726 $1$8300dec7@new s.demon.co.uk.. .[color=blue]
                        > 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[/color]

                        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


                        Comment

                        • Lars Eighner

                          #13
                          Re: trouble with echo &lt;br /&gt;

                          In our last episode,
                          <WemdnUQmq5naYA veRVn-pQ@comcast.com> ,
                          the lovely and talented Khai
                          broadcast on comp.lang.php:

                          [color=blue]
                          > "Colin Fine" <news@kindness. demon.co.uk> wrote in message
                          > news:dn583g$726 $1$8300dec7@new s.demon.co.uk.. .[color=green]
                          >> 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[/color][/color]
                          [color=blue]
                          > I'm looking at the output in the browser (FireFox), and then view source.[/color]
                          [color=blue]
                          > 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>[/color]
                          [color=blue]
                          > *screaming and losing hair*[/color]

                          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 usenet@larseigh ner.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.

                          Comment

                          • Colin Fine

                            #14
                            Re: trouble with echo &lt;br /&gt;

                            Khai wrote:[color=blue]
                            > "Colin Fine" <news@kindness. demon.co.uk> wrote in message
                            > news:dn583g$726 $1$8300dec7@new s.demon.co.uk.. .
                            >[color=green]
                            >>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[/color]
                            >
                            >
                            > 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
                            >
                            >[/color]
                            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

                            Comment

                            • Colin Fine

                              #15
                              Re: trouble with echo &lt;br /&gt;

                              Lars Eighner wrote:[color=blue]
                              > In our last episode,
                              > <WemdnUQmq5naYA veRVn-pQ@comcast.com> ,
                              > the lovely and talented Khai
                              > broadcast on comp.lang.php:
                              >
                              >
                              >[color=green]
                              >>"Colin Fine" <news@kindness. demon.co.uk> wrote in message
                              >>news:dn583g$7 26$1$8300dec7@n ews.demon.co.uk ...
                              >>[color=darkred]
                              >>>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[/color][/color]
                              >
                              >[color=green]
                              >>I'm looking at the output in the browser (FireFox), and then view source.[/color]
                              >
                              >[color=green]
                              >>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>[/color]
                              >
                              >[color=green]
                              >>*screaming and losing hair*[/color]
                              >
                              >
                              > 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>
                              >
                              >[/color]
                              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

                              Comment

                              Working...