Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.php > #3780

Re: Embedding HTML Within a PHP Statement

From Gregor Kofler <usenet@gregorkofler.com>
Newsgroups comp.lang.php
Subject Re: Embedding HTML Within a PHP Statement
Date 2011-11-14 13:54 +0100
Organization A noiseless patient Spider
Message-ID <j9r318$e1d$1@dont-email.me> (permalink)
References <mhg1c7p6qe5ng95rfiguu1b0tu18143m4a@4ax.com>

Show all headers | View raw


Am 2011-11-14 08:29, Call Me Tom meinte:
> I was under the impression that a section of PHP code (the part
> between <?PHP and ?>) was independent of any other section of PHP
> code.  Today I found the following code in a working program:
> 
>    <?php if (!empty($error_message)) { ?>
>    <p class="error"><?php echo $error_message; ?></p>
>    <?php } ?>
> 
> This is the first time I have seen a section of PHP code end in the
> middle of a PHP statement and restart after some HTML was inserted.  I
> was surpised that the PHP interpreter was able to connect the two
> sections of PHP code.
> 
> My question is not how the interpreter does it (that's way beyond my
> level of knowledge) but rather 
>   1. Does this only work in special cases or does it work in all
> cases?

In all. After all PHP started out as a template engine.

>   2. Is it considered good programming, bad programming or personal
> preference?

Depends. I use above constructs frequently in my webpage templates (but
nowhere else).

Gregor

-- 
http://vxweb.net

Back to comp.lang.php | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Embedding HTML Within a PHP Statement Call Me Tom <noemail@nowhere.com> - 2011-11-14 02:29 -0500
  Re: Embedding HTML Within a PHP Statement Erwin Moller <Since_humans_read_this_I_am_spammed_too_much@spamyourself.com> - 2011-11-14 11:10 +0100
    Re: Embedding HTML Within a PHP Statement Balazs Nadasdi <yitsushi@gmail.com> - 2011-11-14 05:07 -0800
      Re: Embedding HTML Within a PHP Statement Jerry Stuckle <jstucklex@attglobal.net> - 2011-11-14 08:19 -0500
        Re: Embedding HTML Within a PHP Statement Balazs Nadasdi <yitsushi@gmail.com> - 2011-11-14 06:41 -0800
          Re: Embedding HTML Within a PHP Statement Jerry Stuckle <jstucklex@attglobal.net> - 2011-11-14 13:59 -0500
            Re: Embedding HTML Within a PHP Statement Balazs Nadasdi <yitsushi@gmail.com> - 2011-11-14 11:41 -0800
              Re: Embedding HTML Within a PHP Statement Jerry Stuckle <jstucklex@attglobal.net> - 2011-11-14 15:22 -0500
                Re: Embedding HTML Within a PHP Statement Balazs Nadasdi <yitsushi@gmail.com> - 2011-11-14 17:44 -0800
      Re: Embedding HTML Within a PHP Statement Erwin Moller <Since_humans_read_this_I_am_spammed_too_much@spamyourself.com> - 2011-11-14 14:29 +0100
      Re: Embedding HTML Within a PHP Statement houghi <houghi@houghi.org.invalid> - 2011-11-14 20:54 +0100
        Re: Embedding HTML Within a PHP Statement Michael Fesser <netizen@gmx.de> - 2011-11-14 21:47 +0100
        Re: Embedding HTML Within a PHP Statement Ross McKay <au.org.zeta.at.rosko@invalid.invalid> - 2011-11-16 09:15 +1100
  Re: Embedding HTML Within a PHP Statement Tim Streater <timstreater@greenbee.net> - 2011-11-14 10:39 +0000
    Re: Embedding HTML Within a PHP Statement Erwin Moller <Since_humans_read_this_I_am_spammed_too_much@spamyourself.com> - 2011-11-14 11:57 +0100
      Re: Embedding HTML Within a PHP Statement The Natural Philosopher <tnp@invalid.invalid> - 2011-11-14 11:49 +0000
      Re: Embedding HTML Within a PHP Statement Tim Streater <timstreater@greenbee.net> - 2011-11-14 12:30 +0000
        Re: Embedding HTML Within a PHP Statement Erwin Moller <Since_humans_read_this_I_am_spammed_too_much@spamyourself.com> - 2011-11-14 15:01 +0100
          Re: Embedding HTML Within a PHP Statement Tim Streater <timstreater@greenbee.net> - 2011-11-14 14:39 +0000
            Re: Embedding HTML Within a PHP Statement Michael Fesser <netizen@gmx.de> - 2011-11-14 18:07 +0100
            Re: Embedding HTML Within a PHP Statement Gregor Kofler <usenet@gregorkofler.com> - 2011-11-15 23:55 +0100
              Re: Embedding HTML Within a PHP Statement Tim Streater <timstreater@greenbee.net> - 2011-11-15 23:02 +0000
                Re: Embedding HTML Within a PHP Statement Gregor Kofler <usenet@gregorkofler.com> - 2011-11-16 00:06 +0100
                Re: Embedding HTML Within a PHP Statement Tim Streater <timstreater@greenbee.net> - 2011-11-16 10:10 +0000
                Re: Embedding HTML Within a PHP Statement Denis McMahon <denismfmcmahon@gmail.com> - 2011-11-16 14:23 +0000
          Re: Embedding HTML Within a PHP Statement Jerry Stuckle <jstucklex@attglobal.net> - 2011-11-14 14:18 -0500
        Re: Embedding HTML Within a PHP Statement Denis McMahon <denismfmcmahon@gmail.com> - 2011-11-14 18:52 +0000
  Re: Embedding HTML Within a PHP Statement Arno Welzel <usenet@arnowelzel.de> - 2011-11-14 13:39 +0100
  Re: Embedding HTML Within a PHP Statement Gregor Kofler <usenet@gregorkofler.com> - 2011-11-14 13:54 +0100
  Re: Embedding HTML Within a PHP Statement Denis McMahon <denismfmcmahon@gmail.com> - 2011-11-14 13:54 +0000
  Re: Embedding HTML Within a PHP Statement bobm3@worthless.info - 2011-11-14 21:15 -0500

csiph-web