Any suggestions about (quotes or <? ?>)

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

    Any suggestions about (quotes or <? ?>)

    Hello again....
    I am coding php in dreamweaver. And because I like to use it for the HTML
    parts I want my HTML code to be unquoted and not into echo statements.

    BUT I ended up in something like this
    <? if ($blabla == 1) { ?>
    <h1> blabla is one <h1>
    <? }
    elseif ($bloublou == 2) { ?>
    <form>
    <input value= <? echo $var ?> ..... >
    </form>
    <ul><? do { ?> <li><h4><? etc..... ?>

    Anyway what I want to know is how can I safely enclose my whole html code
    into an echo statement or anything like echo.



  • Andy Hassall

    #2
    Re: Any suggestions about (quotes or &lt;? ?&gt;)

    On Fri, 20 May 2005 20:32:10 GMT, "Angelos" <adevletoglou@r edcatmedia.net>
    wrote:
    [color=blue]
    >Hello again....
    >I am coding php in dreamweaver. And because I like to use it for the HTML
    >parts I want my HTML code to be unquoted and not into echo statements.
    >
    >BUT I ended up in something like this
    ><? if ($blabla == 1) { ?>
    > <h1> blabla is one <h1>
    ><? }
    >elseif ($bloublou == 2) { ?>
    ><form>
    > <input value= <? echo $var ?> ..... >
    ></form>
    ><ul><? do { ?> <li><h4><? etc..... ?>
    >
    >Anyway what I want to know is how can I safely enclose my whole html code
    >into an echo statement or anything like echo.[/color]

    There's heredoc syntax, such as:

    print <<<END_HTML
    <input type='text' value='$somevar iable'>
    END_HTML;

    Or you could use the alternative control structure syntax which looks neater
    for this sort of layout:

    <?php if ($blabla == 1): ?>
    <h1>blabla is one<h1>
    <?php endif; ?>

    Or just put the whole lot in a multi-line echo if you really want, but watch
    out for quotes.

    --
    Andy Hassall / <andy@andyh.co. uk> / <http://www.andyh.co.uk >
    <http://www.andyhsoftwa re.co.uk/space> Space: disk usage analysis tool

    Comment

    • Mick Sharpe

      #3
      Re: Any suggestions about (quotes or &lt;? ?&gt;)

      > Hello again....[color=blue]
      > I am coding php in dreamweaver. And because I like to use it for the HTML
      > parts I want my HTML code to be unquoted and not into echo statements.
      >
      > BUT I ended up in something like this
      > <? if ($blabla == 1) { ?>
      > <h1> blabla is one <h1>
      > <? }
      > elseif ($bloublou == 2) { ?>
      > <form>
      > <input value= <? echo $var ?> ..... >
      > </form>
      > <ul><? do { ?> <li><h4><? etc..... ?>
      >
      > Anyway what I want to know is how can I safely enclose my whole html code
      > into an echo statement or anything like echo.[/color]

      Look at PEAR HTML Templates- http://pear.php.net/package/HTML_Template_IT -
      they allow you to completely separate your HTML and PHP code.


      Comment

      • Marcin Dobrucki

        #4
        Re: Any suggestions about (quotes or &lt;? ?&gt;)

        Angelos wrote:[color=blue]
        > Hello again....
        > I am coding php in dreamweaver. And because I like to use it for the HTML
        > parts I want my HTML code to be unquoted and not into echo statements.
        >
        > BUT I ended up in something like this
        > <? if ($blabla == 1) { ?>
        > <h1> blabla is one <h1>
        > <? }
        > elseif ($bloublou == 2) { ?>
        > <form>
        > <input value= <? echo $var ?> ..... >
        > </form>
        > <ul><? do { ?> <li><h4><? etc..... ?>[/color]

        Also, please note that with XHTML 1.0 requires you to quote all
        attributes you have in your html. So your <input ...> should actually be:

        <input value="<? echo $var; ?>" ....>

        See reference at:


        /Marcin

        Comment

        • Michael Winter

          #5
          Re: Any suggestions about (quotes or &lt;? ?&gt;)

          On 23/05/2005 12:52, Marcin Dobrucki wrote:

          [snip]
          [color=blue]
          > Also, please note that with XHTML 1.0 requires you to quote all
          > attributes you have in your html.[/color]

          That would have been better written as: XHTML requires you, as an
          author, to quote all attributes in your markup. XHTML has no impact on
          HTML, though it is good practice (in my opinion) to quote all attributes
          and include optional tags.

          However, where did the OP mention the use of XHTML? The errors in the
          posted markup means it doesn't conform to any markup language, let alone
          hint at the strict requirements of XHTML.

          [snip]

          Mike

          --
          Michael Winter
          Replace ".invalid" with ".uk" to reply by e-mail.

          Comment

          Working...