Alternative way of exiting out of php?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
nddwind
Forum Newbie
Posts: 2
Joined: Fri Feb 10, 2006 4:55 pm

Alternative way of exiting out of php?

Post by nddwind »

I was wondering if there was an alternative way of exiting out of a block of php code without using exit, or break;

For example.

<php
I want to break out of this block
?>

//some HTML code here.

<?php
I want it to continue the script here, and execute the html before ?>

The reason being that I have a lot of HTML code at the bottom of my page.

It's more than just HTML code though, otherwise I'd just make a footer.php.

Any help is much appreciated.

Thanks.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

you can mix blocks:

Code: Select all

<?php

// some php

?>
not php
not php
not php
<?php

// more php

if($something) {

?>
outside of php
outside of php
<?php

// back inside the if

}

?>
User avatar
raghavan20
DevNet Resident
Posts: 1451
Joined: Sat Jun 11, 2005 6:57 am
Location: London, UK
Contact:

Post by raghavan20 »

are you looking for an example like this... i am a little confused.. if i am wrong can you explain more...

Code: Select all

<body>
<?php 
	if ($_SERVER["PHP_SELF"] == "myfile.php"){
?>
		hello... my name is myfile.php!!!
<?php
	}else{
?>

		hello... my name is  <?php $_SERVER["PHP_SELF"]; ?>!!!
<?php
	}
?>

</body>
josh
DevNet Master
Posts: 4872
Joined: Wed Feb 11, 2004 3:23 pm
Location: Palm beach, Florida

Post by josh »

Code: Select all

<?php
if ($_GET['myVar']=='test') {
  ?>
   <myHtml>test</myHtml>
  <?php
}
?>
Something like that?

~~~
Opps, I'm too slow
nddwind
Forum Newbie
Posts: 2
Joined: Fri Feb 10, 2006 4:55 pm

Post by nddwind »

I believe so.

I'm a noob to PHP. I'll try that when I get home. Thank you for the replies.
Post Reply