">"

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

    ">"

    Should PHP have allowed ">" to be used within PHP tags?

    e.g. in:

    if (a > b) { ... };

    ....and...

    $object -> member;

    The use of ">" stops PHP pages being valid HTML/XML - by ending
    the current HTML tag - which prevents page validation and the
    use of conventional formatting tools or parsers.
    --
    __________
    |im |yler http://timtyler.org/ tim@tt1lock.org Remove lock to reply.
  • Andy Hassall

    #2
    Re: ">&quot ;

    On Wed, 12 Nov 2003 20:57:36 GMT, Tim Tyler <tim@tt1lock.or g> wrote:
    [color=blue]
    >Should PHP have allowed ">" to be used within PHP tags?[/color]

    Yes.
    [color=blue]
    >e.g. in:
    >
    >if (a > b) { ... };
    >
    >...and...
    >
    >$object -> member;
    >
    >The use of ">" stops PHP pages being valid HTML/XML - by ending
    >the current HTML tag - which prevents page validation and the
    >use of conventional formatting tools or parsers.[/color]

    Only the output of the script has to conform to HTML. Actually that's not even
    true; nobody is limiting you to outputting just HTML or XHTML with PHP; you can
    output whatever you like.

    --
    Andy Hassall (andy@andyh.co. uk) icq(5747695) (http://www.andyh.co.uk)
    Space: disk usage analysis tool (http://www.andyhsoftware.co.uk/space)

    Comment

    • Disco Plumber

      #3
      Re: &quot;&gt;&quot ;

      Andy Hassall (63.620% quality rating):[color=blue]
      >
      > Only the output of the script has to conform to HTML. Actually that's
      > not even true; nobody is limiting you to outputting just HTML or
      > XHTML with PHP; you can output whatever you like.[/color]

      I output NNTP ;)

      /joe
      --
      Thomas Annandale is worthless and great.

      Comment

      • Tim Tyler

        #4
        Re: &quot;&gt;&quot ;

        Andy Hassall <andy@andyh.co. uk> wrote or quoted:[color=blue]
        > On Wed, 12 Nov 2003 20:57:36 GMT, Tim Tyler <tim@tt1lock.or g> wrote:[/color]
        [color=blue][color=green]
        >>Should PHP have allowed ">" to be used within PHP tags?[/color]
        >
        > Yes.
        >[color=green]
        >>e.g. in:
        >>
        >>if (a > b) { ... };
        >>
        >>...and...
        >>
        >>$object -> member;
        >>
        >>The use of ">" stops PHP pages being valid HTML/XML - by ending
        >>the current HTML tag - which prevents page validation and the
        >>use of conventional formatting tools or parsers.[/color]
        >
        > Only the output of the script has to conform to HTML.[/color]

        It prevents users from using existing HTML tools to handle PHP - files -
        such as:

        Web browsers;
        Syntax highlighting;
        Parsers;
        Formatters;
        Lint tools;

        Were using ">=" and "->" really important enough to justify
        violating the HTML specifications?

        Is there a work-around - can you go:

        <?php
        // <!--
        if (a > b) {
        // -->
        ?>

        ....or something?
        [color=blue]
        > Actually that's not even true; nobody is limiting you to outputting
        > just HTML or XHTML with PHP; you can output whatever you like.[/color]

        Well yes - but what does the "H" in "PHP" stand for? ;-)
        --
        __________
        |im |yler http://timtyler.org/ tim@tt1lock.org Remove lock to reply.

        Comment

        • Zurab Davitiani

          #5
          Re: &quot;&gt;&quot ;

          Tim Tyler wrote on Wednesday 12 November 2003 13:25:
          [color=blue]
          > It prevents users from using existing HTML tools to handle PHP - files -
          > such as:
          >
          > Web browsers;
          > Syntax highlighting;
          > Parsers;
          > Formatters;
          > Lint tools;
          >
          > Were using ">=" and "->" really important enough to justify
          > violating the HTML specifications?[/color]

          I don't know what browsers, parsers, or syntax highlighters you are
          referring to, but <?php is a PI in XML, and all of those should be aware of
          that.

          I have no such problems with my editor's hightlighter.

          --
          Business Web Solutions
          ActiveLink, LLC

          Comment

          • Disco Plumber

            #6
            Re: &quot;&gt;&quot ;

            While thinking about how cool Lee Majors was, Tim Tyler blurted:[color=blue]
            >
            > It prevents users from using existing HTML tools to handle PHP - files -
            > such as:[/color]

            Maybe you should use PHP tools or general programming tools rather than
            HTML tools. You're not editing straight HTML.
            [color=blue]
            > Web browsers;[/color]

            Web browsers should not be seeing PHP files, just their output.
            [color=blue]
            > Syntax highlighting;[/color]

            Not if you have the proper syntax highlighting rules.
            [color=blue]
            > Parsers;[/color]

            Not if you have the proper grammar for your parser.
            [color=blue]
            > Formatters;
            > Lint tools;[/color]

            See above, though I'm not sure why you'd use that stuff for PHP.
            [color=blue]
            > Were using ">=" and "->" really important enough to justify
            > violating the HTML specifications?[/color]

            Are you going to invent new symbols for standard operators??

            if($a ^^ $b) // it's "greater than", trust me...

            /joe
            --
            Git.talk.music. emo is beautiful... Matt Hufstetler bogarts Eighth Street
            West and the fetus pot pie. A zen koan from gtpj is kludgy in git.general!
            The hoppy stack is red and odd.

            Comment

            • Andy Hassall

              #7
              Re: &quot;&gt;&quot ;

              On Wed, 12 Nov 2003 21:25:23 GMT, Tim Tyler <tim@tt1lock.or g> wrote:
              [color=blue]
              >Andy Hassall <andy@andyh.co. uk> wrote or quoted:[color=green]
              >> On Wed, 12 Nov 2003 20:57:36 GMT, Tim Tyler <tim@tt1lock.or g> wrote:[/color]
              >[color=green][color=darkred]
              >>>Should PHP have allowed ">" to be used within PHP tags?[/color]
              >>
              >> Yes.
              >>[color=darkred]
              >>>The use of ">" stops PHP pages being valid HTML/XML - by ending
              >>>the current HTML tag - which prevents page validation and the
              >>>use of conventional formatting tools or parsers.[/color]
              >>
              >> Only the output of the script has to conform to HTML.[/color]
              >
              >It prevents users from using existing HTML tools to handle PHP - files -
              >such as:
              >
              >Web browsers;
              >Syntax highlighting;
              >Parsers;
              >Formatters;
              >Lint tools;
              >
              >Were using ">=" and "->" really important enough to justify
              >violating the HTML specifications?[/color]

              But PHP source code is not written in HTML.

              It may have sections in the file that are literal HTML, but that's because
              what PHP _really_ does is allows you to embed HTML in the source code, outside
              the <?php ?> tags - rather than embed PHP in HTML as is generally claimed; so
              you do have some grounds for your argument, but in practice it'd be a real pain
              if PHP source code had to be HTML encoded.

              Odds are you have HTML elements being output in loops etc.; so even the
              sections that are literal HTML may not validate without the actual output of
              executing the PHP.

              You can use '>' in ASP source code as well - and why not?
              [color=blue]
              >Is there a work-around - can you go:
              >
              ><?php
              >// <!--
              >if (a > b) {
              >// -->
              >?>
              >
              >...or something?[/color]

              If that's what keeps your validator/parser/highlighter happy. I'd have thought
              it would complain about <?php first.

              http://www.w3.org/TR/html4/intro/sgmltut.html#h-3.2.4 seems to indicate that
              the following would be OK, and it passes the W3C HTML validator:

              <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
              <html lang="en">
              <head>
              <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
              <title>test</title>
              </head>
              <body>
              <!--
              <?php
              if (a > b) {
              echo 'something';
              }
              ?>
              -->
              </body>
              </html>

              That puts all the PHP inside an HTML comment, including the non-HTML <?php
              tag.

              The validator said:

              "The uploaded file was checked and found to be valid HTML 4.01 Transitional.
              This means that the resource in question identified itself as “HTML 4.01
              Transitional” and that we successfully performed a formal validation using an
              SGML or XML Parser (depending on the markup language used). "

              In fact - just to see what it would complain about - I tried without the
              comment markers. It validated OK. If the validator written by the people who
              wrote the HTML specification is happy...

              PHP doesn't care in the slightest what's 'outside' its tags, so surrounding
              the whole lot in HTML comments won't stop it executing.
              [color=blue][color=green]
              >> Actually that's not even true; nobody is limiting you to outputting
              >> just HTML or XHTML with PHP; you can output whatever you like.[/color]
              >
              >Well yes - but what does the "H" in "PHP" stand for? ;-)[/color]

              Hypertext. Not all hypertext is HTML ;-p
              Should command-line PHP scripts be HTML encoded? ;-p

              if ($a &amp;&amp; $b) anyone? Yuk!

              --
              Andy Hassall (andy@andyh.co. uk) icq(5747695) (http://www.andyh.co.uk)
              Space: disk usage analysis tool (http://www.andyhsoftware.co.uk/space)

              Comment

              • Terence

                #8
                Re: &quot;&gt;&quot ;

                Andy Hassall wrote:
                [color=blue]
                > On Wed, 12 Nov 2003 20:57:36 GMT, Tim Tyler <tim@tt1lock.or g> wrote:
                >
                >[color=green]
                >>Should PHP have allowed ">" to be used within PHP tags?[/color]
                >
                >
                > Yes.
                >[/color]

                Indeed...

                But what PHP shouldn't have done was CONTINUE to allow short_open_tags
                and worse still, CONTINUE to set the default value to "on" ... so now
                this produces a runtime error:

                <?xml version="1.0"?>
                <?xml-stylesheet href="la la la" ?>
                <myRootElemen t>
                <?php // produce XML here ?>
                </myRootElement>

                If short open tags were banned altogether, then updating old scripts
                would be as easy as running a mass search/replace on "<?" with "<?php"

                consequently, the "<?php" notation would/does conform perfectly to the
                XML notation for a processing instruction. And given that these tags
                ("<?php" and "?>") do indeed contain processing instructions for the PHP
                processor, it would be a very elegent integration to XML and XHTML (the
                latest browser standards from the W3C).

                Instead we have the short_open_tag mess >:(

                Comment

                • PenguinsAnonymous

                  #9
                  Re: &quot;&gt;&quot ;

                  Tim Tyler <tim@tt1lock.or g> wrote:[color=blue]
                  > Should PHP have allowed ">" to be used within PHP tags?[/color]
                  [color=blue]
                  > e.g. in:[/color]
                  [color=blue]
                  > if (a > b) { ... };[/color]
                  [color=blue]
                  > ...and...[/color]
                  [color=blue]
                  > $object -> member;[/color]
                  [color=blue]
                  > The use of ">" stops PHP pages being valid HTML/XML - by ending
                  > the current HTML tag - which prevents page validation and the
                  > use of conventional formatting tools or parsers.
                  > --
                  > __________
                  > |im |yler http://timtyler.org/ tim@tt1lock.org Remove lock to reply.[/color]

                  Ohhhhh I see, for the purpose of your formatter :)
                  Well there needs to be a new version of your formatter
                  or configuration that understands the embedded php.
                  Bet it already exhists?
                  -Walt

                  --
                  Reply to innkeepATcapita lDOTnet to email questions.


                  -----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
                  http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
                  -----== Over 100,000 Newsgroups - 19 Different Servers! =-----

                  Comment

                  • Daniel Tryba

                    #10
                    Re: &quot;&gt;&quot ;

                    Tim Tyler <tim@tt1lock.or g> wrote:[color=blue]
                    > The use of ">" stops PHP pages being valid HTML/XML - by ending
                    > the current HTML tag - which prevents page validation and the
                    > use of conventional formatting tools or parsers.[/color]

                    ???

                    If you want to generate valid xml containing valid php:

                    <?xml version='1.0'?>
                    <phpsnippet>
                    <![CDATA[
                    <?php
                    if($a>$b)
                    {
                    echo 'foo';
                    }
                    ?>
                    ]]>
                    </phpsnippet>

                    If you want to treat php as valid xml you'll have a bigger problem with
                    the '<?php' processing instruction than with the characters that should
                    be xml entities used within the php code.

                    --

                    Daniel Tryba

                    Comment

                    • Matty

                      #11
                      Re: &quot;&gt;&quot ;

                      Tim Tyler wrote:
                      [color=blue]
                      > The use of ">" stops PHP pages being valid HTML/XML - by ending
                      > the current HTML tag - which prevents page validation and the
                      > use of conventional formatting tools or parsers.[/color]

                      I fail to see the value in checking PHP code with an X?HTML
                      validator.

                      You can validate the *output* with an html validtion tool
                      with no problems.

                      If you want to use the online variants, you simply need to
                      1 - upload the output
                      2 - make the relevant webserver public

                      You can even download and install the w3c's html validation
                      tools so that you can check your output without having to make
                      it pulicly available.

                      Of yes, you can think about things a little.

                      I do agree, though, that maybe dropping the whole short tags
                      thing might be a good idea...


                      Matt

                      Comment

                      • Tim Tyler

                        #12
                        Re: &quot;&gt;&quot ;

                        Daniel Tryba <news_comp.lang .php@canopus.nl > wrote or quoted:
                        [color=blue]
                        > If you want to treat php as valid xml you'll have a bigger problem with
                        > the '<?php' processing instruction than with the characters that should
                        > be xml entities used within the php code.[/color]

                        There's that as well - but in my experince, the ">" problem is the one
                        with the most unpleasant side effects - since most parsers, etc. ignore
                        tags they don't recognise.
                        --
                        __________
                        |im |yler http://timtyler.org/ tim@tt1lock.org Remove lock to reply.

                        Comment

                        • Tim Tyler

                          #13
                          Re: &quot;&gt;&quot ;

                          Disco Plumber <scag@moralmino rity.org> wrote or quoted:[color=blue]
                          > [...] Tim Tyler blurted:[/color]
                          [color=blue][color=green]
                          >> Were using ">=" and "->" really important enough to justify
                          >> violating the HTML specifications?[/color]
                          >
                          > Are you going to invent new symbols for standard operators??
                          >
                          > if($a ^^ $b) // it's "greater than", trust me...[/color]

                          One option would have been to do it fortran's way - using .gt. and .ge.

                          As for "->" - that is an abomination anyway.
                          --
                          __________
                          |im |yler http://timtyler.org/ tim@tt1lock.org Remove lock to reply.

                          Comment

                          • John Dunlop

                            #14
                            Re: &quot;&gt;&quot ;

                            Terence wrote:
                            [color=blue]
                            > consequently, the "<?php" notation would/does conform perfectly to the
                            > XML notation for a processing instruction.[/color]

                            Hmm. A Processing Instruction (PI) in XML (XML1.0 sec. 2.6,
                            especially production 16), and so XHTML too, begins at "<?" and ends
                            at the first occurrence of "?>". If the string "?>" appeared within
                            the PHP code, the processing instruction would be (prematurely)
                            closed, and the remaining text wouldn't be part of the processing
                            instruction.

                            Trying to validate PHP files against an HTML DTD is equally
                            problematic. Processing Instruction Close (PIC) in HTML is simply
                            ">". So any occurrence of ">" closes the processing instruction. No
                            amount of hiding or commenting-out changes that fact. Thus the absurd
                            notion that ">" shouldn't be allowed within PHP code is akin to
                            arguing that PHP shouldn't allow strings.

                            Remember what the second P in PHP stands for? ;-)
                            [color=blue]
                            > Instead we have the short_open_tag mess >:([/color]

                            Unfortunately.

                            --
                            Jock

                            Comment

                            • Disco Plumber

                              #15
                              Re: &quot;&gt;&quot ;

                              Tim Tyler (8.660% quality rating):[color=blue]
                              >
                              > One option would have been to do it fortran's way[/color]

                              You should realize that this sentence should never be written :)

                              /joe
                              --
                              Elflady digs on Shad Hashmi, and then spars with the bonch. In Publix, the
                              terrorist cell is cantankerous. The blog is huggable and worthless.

                              Comment

                              Working...