break out of <?php... midway thru' an if { } statement ?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi everyone,

------------------------------------- newbie preface ------------------------------------- I finally got some time to come back to learning a little more PHP... and I am looking forward to lots more in coming months, with any luck. Anyway, as I was working towards the last deadline with the PHP project I was working on, I uncovered several issues I did not know the answer to.. and I just hacked around them to avoid taking more time while I was under the clock/meter. Now on my own time, I want to ask, so I learn more deeply what was more ideal understanding/technique. ------------------------------------- /newbie preface -------------------------------------

Here's one of those Q's:

I was working on a system ("MoveableType", A.K.A. "MT") that writes db data to static text files (web pages) whenever the CMS admin tells it to "publish". That system writes out the PHP code that I tell it to, in each page of the site. There was one place in my PHP code (marked with ***MT***, below) where I needed to include a chunk of data that would not be known (or written out) until the admin next published the page (i.e. I could not include the code inline). I needed to display it only in case of a PHP comparison evaluating to true. I was tempted to break out of PHP at that point, and then go back into PHP within that ***MT*** block itself, _only_ when/where in the few places that block needs PHP.. in order to reduce the head pressure (of the less- technical admin using the MT CMS) having to wade through so many PHP print/echo statements (I could not get heredoc to work right, but that is another topic/post ;-). But despite the temptation, I did not attempt that because I thought it might break the logic of the if { } . On the other hand, I vaguely remember reading something that made me think something like that is possible.. but I don't know where I saw it.

To better summarize my Q:

could the below "<mt:Var name="PageMoreNoCRLF">" (which contains a long block of HTML sprinkled with a little PHP whose contents are known only at runtime) be *broken out of* of the <?php ... ?> wrapper that surrounds the if { } statement, and have it still only get displayed on the final webpage when the if { } statement evaluates to true? The reason I want that is so that I can just keep the HTML straight and simple in that MT block, instead of using PHP string- printing statements to spit out it's mostly-pure-HTML contents. The admin using the system is using a WYSIWYG HTML editable textarea interface, kind of like FCKEditor.

if($AlertUser2success != 0) {
	echo '<div class="pg_DIVmainText">'."\n";
echo '<img class="divBGgradient" style="" src="images/ BehindBox01.png" alt="" />'."\n";
			echo '<div>'."\n";
/*--- here is the ***MT*** block/include ---> ---*/ <mt:Var name="PageMoreNoCRLF">
			echo '</div>'."\n";
	echo '</div>'."\n";
} else {
...

------------
Govinda
govinda(DOT)webdnatalk(AT)gmail(DOT)com






--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux