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.
Alternative way of exiting out of php?
Moderator: General Moderators
- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
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
}
?>- raghavan20
- DevNet Resident
- Posts: 1451
- Joined: Sat Jun 11, 2005 6:57 am
- Location: London, UK
- Contact:
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>Code: Select all
<?php
if ($_GET['myVar']=='test') {
?>
<myHtml>test</myHtml>
<?php
}
?>~~~
Opps, I'm too slow