nloding Posted January 27, 2007 Share Posted January 27, 2007 I'm not sure how to accomplish this, if I can at all.Let say I have an if loop that checks for errors, and when it does, I want the PHP script to stop, but I want the HTML to continue ... for instance.I currently have an if statement checking for errors on form submission, and the if statement ends with "exit;". Below the PHP, I have a standard HTML <div> that is my footer, and I want that displayed at all times. If the exit command is processed, the footer div isn't displayed.Other than putting the footer div in it's own include file and including it after each "exit;" command, is there a way to have the PHP stop processing and just skip to the HTML beneath it?[code]<p>This is always displayed, regardless of the error!</p><?php$errormessage = true;if($errormessage){ echo "Oops! Now the footer paragraph is gone!"; exit;}?><p id="footer">Oh no! If that error is there, I'm gone!</p>[/code]I think that code should illustrate what I mean :) Link to comment https://forums.phpfreaks.com/topic/36002-stop-php-parsing-but-not-html/ Share on other sites More sharing options...
Hypnos Posted January 28, 2007 Share Posted January 28, 2007 You could do this...[code]<?phpfunction main() {if(1==2) echo "No candy";else return;echo "I'm stealing your candy!";}?>Candy![/code]But maybe there's a better way that I don't know of. Link to comment https://forums.phpfreaks.com/topic/36002-stop-php-parsing-but-not-html/#findComment-170799 Share on other sites More sharing options...
smc Posted January 28, 2007 Share Posted January 28, 2007 Well one way is to make the entire HTML below the script a variable and display it before exit;My personal way of doing it is I completly seperate HTML and PHP for reasons like this. My way I have all my PHP in the root and HTML in .PHP documents in a templates folderSo that way here is how mine works:[code]if ( $errormessage ) { $resulttext = "Oh snap something hit the fan!"; //You can call an echo in your HTML called resulttext so you can give the error messages require ('templates/myhtmlpage.php'); die;}[/code] Link to comment https://forums.phpfreaks.com/topic/36002-stop-php-parsing-but-not-html/#findComment-170800 Share on other sites More sharing options...
nloding Posted January 28, 2007 Author Share Posted January 28, 2007 Meh, I'll just use an include file for now. Oh well. Link to comment https://forums.phpfreaks.com/topic/36002-stop-php-parsing-but-not-html/#findComment-170811 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.