Page 1 of 1

Alternative way of exiting out of php?

Posted: Fri Feb 10, 2006 5:02 pm
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.

Posted: Fri Feb 10, 2006 5:18 pm
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

}

?>

Posted: Fri Feb 10, 2006 5:18 pm
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>

Posted: Fri Feb 10, 2006 5:19 pm
by josh

Code: Select all

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

~~~
Opps, I'm too slow

Posted: Fri Feb 10, 2006 5:22 pm
by nddwind
I believe so.

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