Mangled Code Mess

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

    Mangled Code Mess

    I have inherited a php script that nests php, javascript, and html.
    How do I clean up code like this:
    I think I can move the javascript into a seperate .js file at the
    least. What about the nesting of php inside the html?

    <?php

    ....snip...

    function ShowCart()
    {
    ...
    ?>
    <html>
    ...
    <script language="JavaS cript">
    function UpdateQty(item, backPage)
    {
    ...
    }
    </script>
    </head>
    <body bgcolor="#fffff f">
    ...
    <?php
    while($row = @mysql_fetch_ar ray($result))
    {
    ...
    ?>
    <tr>
    <td width="15%" height="25">
    <font face="verdana" size="1" color="black">
    <select name="<?php echo $row["itemId"]; ?>"
    onChange="Updat eQty(this,'<?ph p echo $_GET['back']; ?>')">
    ....
    }

  • Willem Bogaerts

    #2
    Re: Mangled Code Mess

    If you print the HTML from the function instead of switching languages,
    legibility will improve significantly and you have more control what
    HTML is generated.

    Best regards

    Skijor wrote:
    I have inherited a php script that nests php, javascript, and html.
    How do I clean up code like this:
    I think I can move the javascript into a seperate .js file at the
    least. What about the nesting of php inside the html?
    >
    <?php
    >
    ...snip...
    >
    function ShowCart()
    {
    ...
    ?>
    <html>
    ...
    <script language="JavaS cript">
    function UpdateQty(item, backPage)
    {
    ...
    }
    </script>
    </head>
    <body bgcolor="#fffff f">
    ...
    <?php
    while($row = @mysql_fetch_ar ray($result))
    {
    ...
    ?>
    <tr>
    <td width="15%" height="25">
    <font face="verdana" size="1" color="black">
    <select name="<?php echo $row["itemId"]; ?>"
    onChange="Updat eQty(this,'<?ph p echo $_GET['back']; ?>')">
    ....
    }
    >

    Comment

    • Jerry Stuckle

      #3
      Re: Mangled Code Mess

      Skijor wrote:
      I have inherited a php script that nests php, javascript, and html.
      How do I clean up code like this:
      I think I can move the javascript into a seperate .js file at the
      least. What about the nesting of php inside the html?
      >
      <?php
      >
      ...snip...
      >
      function ShowCart()
      {
      ...
      ?>
      <html>
      ...
      <script language="JavaS cript">
      function UpdateQty(item, backPage)
      {
      ...
      }
      </script>
      </head>
      <body bgcolor="#fffff f">
      ...
      <?php
      while($row = @mysql_fetch_ar ray($result))
      {
      ...
      ?>
      <tr>
      <td width="15%" height="25">
      <font face="verdana" size="1" color="black">
      <select name="<?php echo $row["itemId"]; ?>"
      onChange="Updat eQty(this,'<?ph p echo $_GET['back']; ?>')">
      ....
      }
      >
      I guess I don't see switching back and forth between html and php as so
      much of a problem. Most WYSIWYG editors won't display html code from an
      echo or print statement, while they will plain html.

      Although I do think this is a little strange - I normally don't have a
      single function which does the headers, etc. Rather, most of my page is
      HTML, with a PHP inserted as required. The code you inherited seems to
      be mostly PHP with a little html thrown in.

      --
      =============== ===
      Remove the "x" from my email address
      Jerry Stuckle
      JDS Computer Training Corp.
      jstucklex@attgl obal.net
      =============== ===

      Comment

      • Double Echo

        #4
        Re: Mangled Code Mess

        This is old-style dirty PHP programming. There are a lot of stupid programmers
        who mingle/mangle code like this trying to be cute. Instead of some HTML
        with PHP thrown in, reverse it. Have PHP with HTML thrown in. PHP should
        be the control, HTML should not be.

        <?php

        $var = 1 + 1 ;

        print <<<ENDOFHTML
        <html>
        <table>
        <tr>
        <td>
        $var
        </td>
        </tr>
        </table>

        ENDOFHTML;

        $some_more_php = 2 + 2 ;

        print <<<ENDOFHTML
        $some_more_php
        ENDOFHMTL;

        ?>

        A lot of web servers won't be set up for HTML-with-PHP but if you have
        a web server with PHP enabled, you can always throw in HTML. Programmers
        who mix PHP into HTML just don't know how to program cleanly.

        -DE-

        Skijor wrote:
        I have inherited a php script that nests php, javascript, and html.
        How do I clean up code like this:
        I think I can move the javascript into a seperate .js file at the
        least. What about the nesting of php inside the html?
        >
        <?php
        >
        ...snip...
        >
        function ShowCart()
        {
        ...
        ?>
        <html>
        ...
        <script language="JavaS cript">
        function UpdateQty(item, backPage)
        {
        ...
        }
        </script>
        </head>
        <body bgcolor="#fffff f">
        ...
        <?php
        while($row = @mysql_fetch_ar ray($result))
        {
        ...
        ?>
        <tr>
        <td width="15%" height="25">
        <font face="verdana" size="1" color="black">
        <select name="<?php echo $row["itemId"]; ?>"
        onChange="Updat eQty(this,'<?ph p echo $_GET['back']; ?>')">
        ....
        }
        >

        Comment

        • bill

          #5
          Re: Mangled Code Mess

          see end of post:

          Double Echo wrote:
          This is old-style dirty PHP programming. There are a lot of stupid
          programmers
          who mingle/mangle code like this trying to be cute. Instead of some HTML
          with PHP thrown in, reverse it. Have PHP with HTML thrown in. PHP
          should be the control, HTML should not be.
          >
          <?php
          >
          $var = 1 + 1 ;
          >
          print <<<ENDOFHTML
          <html>
          <table>
          <tr>
          <td>
          $var
          </td>
          </tr>
          </table>
          >
          ENDOFHTML;
          >
          $some_more_php = 2 + 2 ;
          >
          print <<<ENDOFHTML
          $some_more_php
          ENDOFHMTL;
          >
          ?>
          >
          A lot of web servers won't be set up for HTML-with-PHP but if you have
          a web server with PHP enabled, you can always throw in HTML. Programmers
          who mix PHP into HTML just don't know how to program cleanly.
          >
          -DE-
          >
          DE.
          for a newbie, who likes your style, please reference or explain
          the syntax:

          print <<<ENDOFHTML

          bill

          Comment

          • Curtis

            #6
            Re: Mangled Code Mess

            Here's the PHP manual's page on heredoc syntax:



            On Dec 11, 7:19 am, bill <nob...@spamcop .netwrote:
            see end of post:
            >
            >
            >
            Double Echo wrote:
            This is old-style dirty PHP programming. There are a lot of stupid
            programmers
            who mingle/mangle code like this trying to be cute. Instead of some HTML
            with PHP thrown in, reverse it. Have PHP with HTML thrown in. PHP
            should be the control, HTML should not be.
            >
            <?php
            >
            $var = 1 + 1 ;
            >
            print <<<ENDOFHTML
            <html>
            <table>
            <tr>
            <td>
            $var
            </td>
            </tr>
            </table>
            >
            ENDOFHTML;
            >
            $some_more_php = 2 + 2 ;
            >
            print <<<ENDOFHTML
            $some_more_php
            ENDOFHMTL;
            >
            ?>
            >
            A lot of web servers won't be set up for HTML-with-PHP but if you have
            a web server with PHP enabled, you can always throw in HTML. Programmers
            who mix PHP into HTML just don't know how to program cleanly.
            >
            -DE-DE.
            for a newbie, who likes your style, please reference or explain
            the syntax:
            >
            print <<<ENDOFHTML
            >
            bill

            Comment

            • bill

              #7
              Re: Mangled Code Mess

              Curtis wrote:
              Here's the PHP manual's page on heredoc syntax:
              >
              http://php.net/manual/en/language.ty...syntax.heredoc
              many thanks, that is great.

              bill
              >
              On Dec 11, 7:19 am, bill <nob...@spamcop .netwrote:
              >see end of post:
              >>
              >>
              >>
              >Double Echo wrote:
              >>This is old-style dirty PHP programming. There are a lot of stupid
              >>programmers
              >>who mingle/mangle code like this trying to be cute. Instead of some HTML
              >>with PHP thrown in, reverse it. Have PHP with HTML thrown in. PHP
              >>should be the control, HTML should not be.
              >><?php
              >>$var = 1 + 1 ;
              >>print <<<ENDOFHTML
              >><html>
              >><table>
              >><tr>
              >><td>
              >>$var
              >></td>
              >></tr>
              >></table>
              >>ENDOFHTML;
              >>$some_more_ph p = 2 + 2 ;
              >>print <<<ENDOFHTML
              >>$some_more_ph p
              >>ENDOFHMTL;
              >>?>
              >>A lot of web servers won't be set up for HTML-with-PHP but if you have
              >>a web server with PHP enabled, you can always throw in HTML. Programmers
              >>who mix PHP into HTML just don't know how to program cleanly.
              >>-DE-DE.
              >for a newbie, who likes your style, please reference or explain
              >the syntax:
              >>
              >print <<<ENDOFHTML
              >>
              >bill
              >

              Comment

              • bill

                #8
                Re: Mangled Code Mess

                Curtis wrote:
                Here's the PHP manual's page on heredoc syntax:
                >

                >
                On Dec 11, 7:19 am, bill <nob...@spamcop .netwrote:
                >see end of post:
                >>
                >>
                >>
                >Double Echo wrote:
                >>This is old-style dirty PHP programming. There are a lot of stupid
                >>programmers
                >>who mingle/mangle code like this trying to be cute. Instead of some HTML
                >>with PHP thrown in, reverse it. Have PHP with HTML thrown in. PHP
                >>should be the control, HTML should not be.
                >><?php
                >>$var = 1 + 1 ;
                >>print <<<ENDOFHTML
                >><html>
                >><table>
                >><tr>
                >><td>
                >>$var
                >></td>
                >></tr>
                >></table>
                >>ENDOFHTML;
                >>$some_more_ph p = 2 + 2 ;
                >>print <<<ENDOFHTML
                >>$some_more_ph p
                >>ENDOFHMTL;
                >>?>
                >>A lot of web servers won't be set up for HTML-with-PHP but if you have
                >>a web server with PHP enabled, you can always throw in HTML. Programmers
                >>who mix PHP into HTML just don't know how to program cleanly.
                >>-DE-DE.
                >for a newbie, who likes your style, please reference or explain
                >the syntax:
                >>
                >print <<<ENDOFHTML
                >>
                >bill
                >
                That sure will make writing html with embedded PHP variables a
                LOT more straightforward !

                bill

                Comment

                • Skijor

                  #9
                  Re: Mangled Code Mess

                  Thanks all.

                  As far as the JavaScript definitions go, is there really a good reason
                  to generate the functions on the fly like this? I assume I can just
                  statically define them in a .js file instead of creating them on the
                  fly every time my php code is called. The assumption being I replace
                  the function definitions with function calls in the php-generated HTML.


                  bill wrote:
                  Curtis wrote:
                  Here's the PHP manual's page on heredoc syntax:



                  On Dec 11, 7:19 am, bill <nob...@spamcop .netwrote:
                  see end of post:
                  >
                  >
                  >
                  Double Echo wrote:
                  >This is old-style dirty PHP programming. There are a lot of stupid
                  >programmers
                  >who mingle/mangle code like this trying to be cute. Instead of some HTML
                  >with PHP thrown in, reverse it. Have PHP with HTML thrown in. PHP
                  >should be the control, HTML should not be.
                  ><?php
                  >$var = 1 + 1 ;
                  >print <<<ENDOFHTML
                  ><html>
                  ><table>
                  ><tr>
                  ><td>
                  >$var
                  ></td>
                  ></tr>
                  ></table>
                  >ENDOFHTML;
                  >$some_more_p hp = 2 + 2 ;
                  >print <<<ENDOFHTML
                  >$some_more_p hp
                  >ENDOFHMTL;
                  >?>
                  >A lot of web servers won't be set up for HTML-with-PHP but if you have
                  >a web server with PHP enabled, you can always throw in HTML. Programmers
                  >who mix PHP into HTML just don't know how to program cleanly.
                  >-DE-DE.
                  for a newbie, who likes your style, please reference or explain
                  the syntax:
                  >
                  print <<<ENDOFHTML
                  >
                  bill
                  >
                  That sure will make writing html with embedded PHP variables a
                  LOT more straightforward !
                  >
                  bill

                  Comment

                  • Curtis

                    #10
                    Re: Mangled Code Mess

                    As long as the JavaScript isn't relying on data passed by PHP, you
                    should be fine by storing the JS in its own file, which is usually the
                    case. Usually, it's best to keep the presentation tier separate from
                    the business logic anyway.

                    Curtis

                    Skijor wrote:
                    Thanks all.
                    >
                    As far as the JavaScript definitions go, is there really a good reason
                    to generate the functions on the fly like this? I assume I can just
                    statically define them in a .js file instead of creating them on the
                    fly every time my php code is called. The assumption being I replace
                    the function definitions with function calls in the php-generated HTML.
                    >
                    >
                    bill wrote:
                    Curtis wrote:
                    Here's the PHP manual's page on heredoc syntax:
                    >

                    >
                    On Dec 11, 7:19 am, bill <nob...@spamcop .netwrote:
                    >see end of post:
                    >>
                    >>
                    >>
                    >Double Echo wrote:
                    >>This is old-style dirty PHP programming. There are a lot of stupid
                    >>programmers
                    >>who mingle/mangle code like this trying to be cute. Instead of some HTML
                    >>with PHP thrown in, reverse it. Have PHP with HTML thrown in. PHP
                    >>should be the control, HTML should not be.
                    >><?php
                    >>$var = 1 + 1 ;
                    >>print <<<ENDOFHTML
                    >><html>
                    >><table>
                    >><tr>
                    >><td>
                    >>$var
                    >></td>
                    >></tr>
                    >></table>
                    >>ENDOFHTML;
                    >>$some_more_ph p = 2 + 2 ;
                    >>print <<<ENDOFHTML
                    >>$some_more_ph p
                    >>ENDOFHMTL;
                    >>?>
                    >>A lot of web servers won't be set up for HTML-with-PHP but if you have
                    >>a web server with PHP enabled, you can always throw in HTML. Programmers
                    >>who mix PHP into HTML just don't know how to program cleanly.
                    >>-DE-DE.
                    >for a newbie, who likes your style, please reference or explain
                    >the syntax:
                    >>
                    >print <<<ENDOFHTML
                    >>
                    >bill
                    >
                    That sure will make writing html with embedded PHP variables a
                    LOT more straightforward !

                    bill

                    Comment

                    • Double Echo

                      #11
                      Re: Mangled Code Mess

                      Bill,

                      Sorry for not getting back sooner... had a lot of work interrupting my newsgroup time. :-)

                      Here-doc allows you to basically print out whatever is between the pattern you choose.

                      I use ENDOFHTML but you could use ENDOFCODE or whatever.

                      Perl has a similar construct:

                      print <<ENDOFHTML;
                      ENDOFHTML

                      Notice the semi-colon at the top, PHP is a bit more "correct" putting the semi-colon at
                      the end:

                      print <<<ENDOFHTML
                      ENDOFHTML;

                      PHP also uses "<<<" whereas Perl uses "<<".

                      Anyway, embedded PHP programs were the rave a couple of years ago, and people were doing
                      it trying to create really dynamic pages, but it's really messy as you've found out to
                      do it that way.

                      It's easier to print <<<EDNDOFHTML because you can actually use ' and "
                      in the block without trouble. There are also a lot of web servers that don't like embedded
                      PHP in HTML docs and will barf or ignore it if you attempt it. So, it's better to embed HTML in PHP,
                      and save yourself the hassle. One note, be careful about the placement at the end, the
                      end tag _must_ be over at the left, and no space after it, or it won't work.



                      bill wrote:
                      see end of post:
                      >
                      Double Echo wrote:
                      >This is old-style dirty PHP programming. There are a lot of stupid
                      >programmers
                      >who mingle/mangle code like this trying to be cute. Instead of some HTML
                      >with PHP thrown in, reverse it. Have PHP with HTML thrown in. PHP
                      >should be the control, HTML should not be.
                      >>
                      ><?php
                      >>
                      >$var = 1 + 1 ;
                      >>
                      >print <<<ENDOFHTML
                      ><html>
                      ><table>
                      ><tr>
                      ><td>
                      >$var
                      ></td>
                      ></tr>
                      ></table>
                      >>
                      >ENDOFHTML;
                      >>
                      >$some_more_p hp = 2 + 2 ;
                      >>
                      >print <<<ENDOFHTML
                      >$some_more_p hp
                      >ENDOFHMTL;
                      >>
                      >?>
                      >>
                      >A lot of web servers won't be set up for HTML-with-PHP but if you have
                      >a web server with PHP enabled, you can always throw in HTML. Programmers
                      >who mix PHP into HTML just don't know how to program cleanly.
                      >>
                      >-DE-
                      >>
                      DE.
                      for a newbie, who likes your style, please reference or explain the syntax:
                      >
                      print <<<ENDOFHTML
                      >
                      bill

                      Comment

                      • Tim Streater

                        #12
                        Re: Mangled Code Mess

                        In article <bIegh.1422$lc1 .1288@fe56.usen etserver.com>,
                        Double Echo <doubleecho@you r.comwrote:
                        Bill,
                        >
                        Sorry for not getting back sooner... had a lot of work interrupting my
                        newsgroup time. :-)
                        >
                        Here-doc allows you to basically print out whatever is between the pattern
                        you choose.
                        >
                        I use ENDOFHTML but you could use ENDOFCODE or whatever.
                        >
                        Perl has a similar construct:
                        >
                        print <<ENDOFHTML;
                        ENDOFHTML
                        >
                        Notice the semi-colon at the top, PHP is a bit more "correct" putting the
                        semi-colon at
                        the end:
                        >
                        print <<<ENDOFHTML
                        ENDOFHTML;
                        >
                        PHP also uses "<<<" whereas Perl uses "<<".
                        >
                        Anyway, embedded PHP programs were the rave a couple of years ago, and people
                        were doing
                        it trying to create really dynamic pages, but it's really messy as you've
                        found out to
                        do it that way.
                        >
                        It's easier to print <<<EDNDOFHTML because you can actually use ' and "
                        in the block without trouble. There are also a lot of web servers that don't
                        like embedded
                        PHP in HTML docs and will barf or ignore it if you attempt it. So, it's
                        better to embed HTML in PHP,
                        and save yourself the hassle.
                        No, I've gone away from this approach and had no problems at all. My
                        pages embed the PHP in the HTML. Its a lot easier that way. I use PHP to
                        dynamically generate the html based on what is in our mysql database.

                        -- tim

                        Comment

                        • Double Echo

                          #13
                          Re: Mangled Code Mess

                          Tim Streater wrote:
                          In article <bIegh.1422$lc1 .1288@fe56.usen etserver.com>,
                          Double Echo <doubleecho@you r.comwrote:
                          >
                          >Bill,
                          >>
                          >Sorry for not getting back sooner... had a lot of work interrupting my
                          >newsgroup time. :-)
                          >>
                          >Here-doc allows you to basically print out whatever is between the pattern
                          >you choose.
                          >>
                          >I use ENDOFHTML but you could use ENDOFCODE or whatever.
                          >>
                          >Perl has a similar construct:
                          >>
                          >print <<ENDOFHTML;
                          >ENDOFHTML
                          >>
                          >Notice the semi-colon at the top, PHP is a bit more "correct" putting the
                          >semi-colon at
                          >the end:
                          >>
                          >print <<<ENDOFHTML
                          >ENDOFHTML;
                          >>
                          >PHP also uses "<<<" whereas Perl uses "<<".
                          >>
                          >Anyway, embedded PHP programs were the rave a couple of years ago, and people
                          >were doing
                          >it trying to create really dynamic pages, but it's really messy as you've
                          >found out to
                          >do it that way.
                          >>
                          >It's easier to print <<<EDNDOFHTML because you can actually use ' and "
                          >in the block without trouble. There are also a lot of web servers that don't
                          >like embedded
                          >PHP in HTML docs and will barf or ignore it if you attempt it. So, it's
                          >better to embed HTML in PHP,
                          >and save yourself the hassle.
                          >
                          No, I've gone away from this approach and had no problems at all. My
                          pages embed the PHP in the HTML. Its a lot easier that way. I use PHP to
                          dynamically generate the html based on what is in our mysql database.
                          >
                          -- tim

                          It might be easier for _you_, but not for the next poor bastard that will have
                          to agonize at the shitmess you made.

                          There is no excuse for shitty-looking code. Another annoyance for me are people
                          who have to roll-up their brackets as if there is a line penalty for good, structured
                          code. Like you're going to run out of lines or air or something.

                          People who like to

                          if (...) {
                          }

                          or

                          while(...) {
                          }

                          annoy the fuck-out-of-me because I have to stop, read really slowly and try to grasp
                          the nesting, and logic. It's all rolled up so you can't hardly separate the code into
                          something readable.

                          It's so much cleaner to

                          if ( ... )
                          {
                          code here
                          }

                          or

                          while( ... )
                          {
                          code here
                          }

                          but all the goddam schools preach shitmess roll-up coding and OO. It works but it's so fucking
                          messy. You fucking kids think it's cool code, and wow, neato, but then somebody else has to
                          work on it, and it's a fucking nightmare. Clean code, nested, and properly written will allow
                          the code to be debugged better, and probably survive being re-written all over again because you
                          can actually read it. I've gone on to delete code I can't read and just re-wrote it cleanly.

                          -DE- ( using my best Dr. House imitation )


                          Comment

                          • Jerry Stuckle

                            #14
                            Re: Mangled Code Mess

                            Tim Streater wrote:
                            In article <bIegh.1422$lc1 .1288@fe56.usen etserver.com>,
                            Double Echo <doubleecho@you r.comwrote:
                            >
                            >
                            >>Bill,
                            >>
                            >>Sorry for not getting back sooner... had a lot of work interrupting my
                            >>newsgroup time. :-)
                            >>
                            >>Here-doc allows you to basically print out whatever is between the pattern
                            >>you choose.
                            >>
                            >>I use ENDOFHTML but you could use ENDOFCODE or whatever.
                            >>
                            >>Perl has a similar construct:
                            >>
                            >>print <<ENDOFHTML;
                            >>ENDOFHTML
                            >>
                            >>Notice the semi-colon at the top, PHP is a bit more "correct" putting the
                            >>semi-colon at
                            >>the end:
                            >>
                            >>print <<<ENDOFHTML
                            >>ENDOFHTML;
                            >>
                            >>PHP also uses "<<<" whereas Perl uses "<<".
                            >>
                            >>Anyway, embedded PHP programs were the rave a couple of years ago, and people
                            >>were doing
                            >>it trying to create really dynamic pages, but it's really messy as you've
                            >>found out to
                            >>do it that way.
                            >>
                            >>It's easier to print <<<EDNDOFHTML because you can actually use ' and "
                            >>in the block without trouble. There are also a lot of web servers that don't
                            >>like embedded
                            >>PHP in HTML docs and will barf or ignore it if you attempt it. So, it's
                            >>better to embed HTML in PHP,
                            >>and save yourself the hassle.
                            >
                            >
                            No, I've gone away from this approach and had no problems at all. My
                            pages embed the PHP in the HTML. Its a lot easier that way. I use PHP to
                            dynamically generate the html based on what is in our mysql database.
                            >
                            -- tim
                            Hi, Tim,

                            I agree with you. And I find this style, even when written by someone
                            else, to be much easier to follow than echoing everything from PHP.

                            But it's a matter of programming style. Some like it, some don't.



                            --
                            =============== ===
                            Remove the "x" from my email address
                            Jerry Stuckle
                            JDS Computer Training Corp.
                            jstucklex@attgl obal.net
                            =============== ===

                            Comment

                            • Jerry Stuckle

                              #15
                              Re: Mangled Code Mess

                              Double Echo wrote:
                              Tim Streater wrote:
                              >
                              >In article <bIegh.1422$lc1 .1288@fe56.usen etserver.com>,
                              > Double Echo <doubleecho@you r.comwrote:
                              >>
                              >>Bill,
                              >>>
                              >>Sorry for not getting back sooner... had a lot of work interrupting
                              >>my newsgroup time. :-)
                              >>>
                              >>Here-doc allows you to basically print out whatever is between the
                              >>pattern you choose.
                              >>>
                              >>I use ENDOFHTML but you could use ENDOFCODE or whatever.
                              >>>
                              >>Perl has a similar construct:
                              >>>
                              >>print <<ENDOFHTML;
                              >>ENDOFHTML
                              >>>
                              >>Notice the semi-colon at the top, PHP is a bit more "correct" putting
                              >>the semi-colon at
                              >>the end:
                              >>>
                              >>print <<<ENDOFHTML
                              >>ENDOFHTML;
                              >>>
                              >>PHP also uses "<<<" whereas Perl uses "<<".
                              >>>
                              >>Anyway, embedded PHP programs were the rave a couple of years ago,
                              >>and people were doing
                              >>it trying to create really dynamic pages, but it's really messy as
                              >>you've found out to do it that way.
                              >>It's easier to print <<<EDNDOFHTML because you can actually use ' and "
                              >>in the block without trouble. There are also a lot of web servers
                              >>that don't like embedded
                              >>PHP in HTML docs and will barf or ignore it if you attempt it. So,
                              >>it's better to embed HTML in PHP,
                              >>and save yourself the hassle.
                              >>
                              >>
                              >No, I've gone away from this approach and had no problems at all. My
                              >pages embed the PHP in the HTML. Its a lot easier that way. I use PHP
                              >to dynamically generate the html based on what is in our mysql database.
                              >>
                              >-- tim
                              >
                              >
                              >
                              It might be easier for _you_, but not for the next poor bastard that
                              will have
                              to agonize at the shitmess you made.
                              >
                              I disagree. I like this style also, and find this style to be much
                              easier to troubleshoot and modify than echoing everything from PHP.
                              There is no excuse for shitty-looking code. Another annoyance for me
                              are people
                              who have to roll-up their brackets as if there is a line penalty for
                              good, structured
                              code. Like you're going to run out of lines or air or something.
                              >
                              Agreed. And personally, I think your style looks pretty shitty. But
                              it's only my opinion, and it's a matter of what you're used to.
                              People who like to
                              if (...) {
                              }
                              >
                              or
                              >
                              while(...) {
                              }
                              >
                              annoy the fuck-out-of-me because I have to stop, read really slowly and
                              try to grasp
                              the nesting, and logic. It's all rolled up so you can't hardly separate
                              the code into
                              something readable.
                              >
                              And I find hundreds of unnecessary echo statements to be unnecessarily
                              ugly and complicating.
                              It's so much cleaner to
                              >
                              if ( ... )
                              {
                              code here
                              }
                              >
                              or
                              while( ... )
                              {
                              code here
                              }
                              >
                              Sure. But when you add dozens of echo statements in your braces, it
                              gets a lot more complicated. And when you start concatenating strings
                              together to get variables and html... terrible!
                              but all the goddam schools preach shitmess roll-up coding and OO. It
                              works but it's so fucking
                              messy. You fucking kids think it's cool code, and wow, neato, but then
                              somebody else has to
                              work on it, and it's a fucking nightmare. Clean code, nested, and
                              properly written will allow
                              the code to be debugged better, and probably survive being re-written
                              all over again because you
                              can actually read it. I've gone on to delete code I can't read and just
                              re-wrote it cleanly.
                              >
                              -DE- ( using my best Dr. House imitation )
                              >
                              >
                              Well, if "all the goddam schools" teach it, there must be something to
                              it, don't you think?

                              --
                              =============== ===
                              Remove the "x" from my email address
                              Jerry Stuckle
                              JDS Computer Training Corp.
                              jstucklex@attgl obal.net
                              =============== ===

                              Comment

                              Working...