Flow Control Spanning Multiple PHP Tags : "Technical Term"
Posted: Sun Aug 14, 2011 3:14 am
Dear All -
Consider the following HTML/PHP mix:
Say the code above is the contents of a file [text]iota.php[/text] and I point my browser to it, and I see this:
Pantone 292
This seems to be fine PHP coding. I see it in common use, and found some sites about it in my searchings. People rely on this type of PHP-controlled HTML block technique working, and get bent out of shape when their favorite IDE paints it otherwise.
But what is the technical term for the programming concept demonstrated here, whereby a control statement in a PHP program can exist over two separate tags?
I'm asking so I know better what search terms to use to look up more specific documentation on this construction.
As either an irrelevant side-note or a slam-dunk proof-of-something-ness (I'm not sure which), note that
works OK, but, moving the first closing bracket over into the first tag,
generates an error.
- Louis
PS seems to work OK.
Consider the following HTML/PHP mix:
Code: Select all
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<TITLE> A PHP-HTML-PHP Control Sandwich </TITLE>
<?php $makes_me_feel = "blue" ; ?>
<html>
<body>
<?php if( $makes_me_feel == "blue" ) { ?>
<a href="http://www.google.com/search?q=pantone+292" >
Pantone 292
</a>
<?php } ?>
</body>
</html>
Pantone 292
This seems to be fine PHP coding. I see it in common use, and found some sites about it in my searchings. People rely on this type of PHP-controlled HTML block technique working, and get bent out of shape when their favorite IDE paints it otherwise.
But what is the technical term for the programming concept demonstrated here, whereby a control statement in a PHP program can exist over two separate tags?
I'm asking so I know better what search terms to use to look up more specific documentation on this construction.
As either an irrelevant side-note or a slam-dunk proof-of-something-ness (I'm not sure which), note that
Code: Select all
<? if(expression) { ?> HTML-block <? } else { ?><? } ?>Code: Select all
<? if(expression) { } ?> HTML-block <? else { ?><? } ?>- Louis
PS
Code: Select all
<? if(expression) { expression-list ?> HTML-block <? expression-list } ?>