Using ECHO once per page or incidentally

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

    Using ECHO once per page or incidentally

    I read a short thread at php.net regarding the use of ECHO.

    I have an HTML form with PHP variables to define each input value (if any.)

    For example:

    <input type='text' name='firstname ' value='<?php echo $FirstName; ?>'>

    I'm wondering if it makes any sense (performance and code-efficiency wise)
    to do as follows:

    <?php

    echo("

    <input type='text' name='firstname ' value='$FirstNa me'>

    ");
    ?>

    Besides less typing, is there any additional benefits to wrapping the whole
    form in PHP tags? Is there any drawbacks?

    All comments welcome. Thanks.


  • neur0maniak

    #2
    Re: Using ECHO once per page or incidentally

    Xenophobe wrote:[color=blue]
    > I read a short thread at php.net regarding the use of ECHO.
    >
    > I have an HTML form with PHP variables to define each input value (if any.)
    >
    > For example:
    >
    > <input type='text' name='firstname ' value='<?php echo $FirstName; ?>'>
    >
    > I'm wondering if it makes any sense (performance and code-efficiency wise)
    > to do as follows:
    >
    > <?php
    >
    > echo("
    >
    > <input type='text' name='firstname ' value='$FirstNa me'>
    >
    > ");
    > ?>
    >
    > Besides less typing, is there any additional benefits to wrapping the whole
    > form in PHP tags? Is there any drawbacks?
    >
    > All comments welcome. Thanks.
    >
    >[/color]
    I find it's just a pain in the ass to go around making sure everything
    it escaped properly when I print things out in full... I also like to
    make my page source code look clean (in HTML source and in PHP source),
    and printing it out in PHP, it's a lot harder to do...

    Comment

    • steve

      #3
      Re: Using ECHO once per page or incidentally

      "Xenophobe" wrote:[color=blue]
      > I read a short thread at php.net regarding the use of ECHO.
      >
      > I have an HTML form with PHP variables to define each input value[/color]
      (if[color=blue]
      > any.)
      >
      > For example:
      >
      > <input type=’text’ name=’firstname ’
      > value=’<?php echo $FirstName; ?>’>
      >
      > I’m wondering if it makes any sense (performance and
      > code-efficiency wise)
      > to do as follows:
      >
      > <?php
      >
      > echo("
      >
      > <input type=’text’ name=’firstname ’
      > value=’$FirstNa me’>
      >
      > ");
      > ?>
      >
      > Besides less typing, is there any additional benefits to wrapping[/color]
      the[color=blue]
      > whole
      > form in PHP tags? Is there any drawbacks?
      >
      > All comments welcome. Thanks.[/color]

      These kinds of things don’t make much different from efficiency
      standpoint. 99% of your performance is related to database access.

      Enclosing in "" is nice for programming, so you don’ t have to say
      "$aaa" . "\n" . "$bbbb"
      You can simply say "$aaa\n$bbb "
      Beyond that, I would not worry about it.

      --
      http://www.dbForumz.com/ This article was posted by author's request
      Articles individually checked for conformance to usenet standards
      Topic URL: http://www.dbForumz.com/PHP-ECHO-pag...ict130553.html
      Visit Topic URL to contact author (reg. req'd). Report abuse: http://www.dbForumz.com/eform.php?p=435756

      Comment

      • Markus Ernst

        #4
        Re: Using ECHO once per page or incidentally

        "Xenophobe" <xenophobe@plan etx.com> schrieb im Newsbeitrag
        news:cqqKc.8512 9$WX.83526@attb i_s51...[color=blue]
        > I read a short thread at php.net regarding the use of ECHO.[/color]

        [...]
        [color=blue]
        > <input type='text' name='firstname ' value='<?php echo $FirstName; ?>'>[/color]

        This is easy to read and easily editable with an editor such as Dreamveawer
        or GoLive.

        [...]
        [color=blue]
        > <?php
        >
        > echo("
        >
        > <input type='text' name='firstname ' value='$FirstNa me'>
        >
        > ");
        > ?>[/color]

        This might be efficient if there is only little HTML in lots of PHP.

        Actually it depends on your preferences and on the circumstances of the
        project. If the page should be editable by others (maybe even by a designer
        who does not know a lot about the PHP parts of it), I would in most cases
        prefer the first solution.

        --
        Markus


        Comment

        Working...