Frequent Mode Switching

Ask a Question related to PHP Development, Design and Development.

  1. #1

    Default Re: Frequent Mode Switching


    "Derrick Fogle" <derrick@foundationcomputing.com> wrote in message
    news:B4735EB9-C789-11D7-9AA8-000393C7877A@foundationcomputing.com...
    > Thoughts on frequent switching in and out of PHP mode:
    >
    > <? switch in, do some code
    > ?>Switch out, static HTML
    > <? switch in, do more code
    > ?>Switch out, more static HTML
    >
    > I've found that I prefer programming this way, for the most part,
    > putting most of the heavy PHP programming at the top, and then using
    > static HTML interspersed mostly with quick <?= $variable ?> statements
    > for what users see.
    >
    > I'm sure there's more than one viewpoint out there, so I'd like to hear
    > a couple of them. Is this frequent mode switching good, bad, or
    > indifferent? Is there a point at which the mode switching starts to
    > seriously degrade performance and reliability?
    >
    > -Derrick

    I used to program that way. The logic and presentation portions of my
    scripts were combined into one or two monolithic files. That worked well
    for small projects. But as I got involved in larger projects and had to
    juggle many code files at once I found that I prefered to separate as much
    of the HTML from the PHP code as possible.

    Typically what I do now is set up my HTML in a template-like format using
    <?= $var?> as the outputs. Very little logic goes between the <?php?> tags
    in my HTML files but of course sometimes it's unaviodable and that's why you
    want to use <?php?> tags here and not some phoney template language. Then
    sipmly include() the HTML file back into the script allowing the outputs to
    fill in. This makes for a very 'plastic' interface that you can mold very
    easily in an HTML editor without screwing up your script. For example I did
    a calendar script recently with the following outputs...

    $next_year
    $prev_year
    $cur_year
    $cur_month
    $cur_day
    $january
    $february
    $march
    $april
    $may
    $june
    $july
    $august
    $september
    $october
    $november
    $december
    $event_list
    $event_header

    Each output contains a portion of the final calendar page. So I could take
    the months and put them into rows or columns, take the event list and put it
    on the top or the bottom, take the interface elements and place them where
    they work best. Or I can ignore half of the outputs and display only one
    month if I wanted to. Point being I could do this in a fraction of the time
    it would take me to do it in logic portion of the script.

    Anyway.. just my two bits. Take it or leave it. :-)

    - Kevin


    Kevin Stone Guest

  2. Similar Questions and Discussions

    1. Frequent quitting
      I have a project running that consists of a series of medium resolution images playing randomly. It's on a recently purchased Windows XP machine...
    2. PS CS crashing when switching screen mode
      I'm freezing up when hot keying through screen mode quickly. This doesn't happen when I do slowly. I'm on a G5 running10.3.2. Anyone have similar...
    3. frequent crashes
      Yes me too. I tried ditching the prefs and Apple's disk utility. Still the same. It seems more stable for a while after doing this and then off...
    4. frequent CS crashes on a new g5
      Something is wrong, i just purchased a new dual g5, with 2 gigs or ram runing panther and photoshopCS. and it keeps crashing, about an hour after i...
    5. [PHP] Frequent Mode Switching
      This method has been my personal choice for the past 3-4 yrs in coding, I have not found any problems with it thus far. But I am gradually...
  3. #2

    Default Re: [PHP] Re: Frequent Mode Switching



    Kevin Stone wrote:
    >
    >I used to program that way. The logic and presentation portions of my
    >scripts were combined into one or two monolithic files. That worked well
    >for small projects. But as I got involved in larger projects and had to
    >juggle many code files at once I found that I prefered to separate as much
    >of the HTML from the PHP code as possible.
    >
    >
    >Typically what I do now is set up my HTML in a template-like format using
    ><?= $var?> as the outputs.
    >
    <?= is discouraged and is known to break some files, the full use if
    <?php is encouraged, they have been several threads discussing the use
    of <?= and where there is not a <?php=, search the archives for more
    information.

    Jason
    >
    >$next_year
    >$prev_year
    >$cur_year
    >$cur_month
    >$cur_day
    >$january
    >$february
    >$march
    >$april
    >$may
    >$june
    >$july
    >$august
    >$september
    >$october
    >$november
    >$december
    >$event_list
    >$event_header
    >
    >Each output contains a portion of the final calendar page. So I could take
    >the months and put them into rows or columns, take the event list and put it
    >on the top or the bottom, take the interface elements and place them where
    >they work best. Or I can ignore half of the outputs and display only one
    >month if I wanted to. Point being I could do this in a fraction of the time
    >it would take me to do it in logic portion of the script.
    >
    >Anyway.. just my two bits. Take it or leave it. :-)
    >
    >- Kevin
    >
    >
    >
    >
    >
    Jason Sheets Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139