Re: Embedding HTML Within a PHP Statement [message #175990 is a reply to message #175980] |
Mon, 14 November 2011 12:54 |
Gregor Kofler
Messages: 69 Registered: September 2010
Karma:
|
Member |
|
|
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
|
|
|