FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » Embedding HTML Within a PHP Statement
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: Embedding HTML Within a PHP Statement [message #175995 is a reply to message #175980] Mon, 14 November 2011 13:54 Go to previous messageGo to previous message
Denis McMahon is currently offline  Denis McMahon
Messages: 634
Registered: September 2010
Karma:
Senior Member
On Mon, 14 Nov 2011 02:29:30 -0500, Call Me Tom wrote:

> 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:

Nope. All the php code in a script shares the same environment.

eg in a single file:

-----------------------------------------
<?php
// some code
?>

some html

<?php
// some more code
?>

more html

<?php
// even more code
?>
-----------------------------------------

all the php code is operating with the same variables etc.

This means you can:

<?php
if (condition) {
?>

some html

<?php
}
?>

It might not be the tidiest way to do it (using heredoc is usually
tidier), and I'm sure at least one purist will say "you shouldn't do it
like that" but it works and it's valid php.

Rgds

Denis McMahon
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Smart File Downloader - simple script on xampp
Next Topic: Prevent unlink(...) warning
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Mon Nov 25 04:27:25 GMT 2024

Total time taken to generate the page: 0.05432 seconds