Let’s say I have some code like this:
<html> <head><title>Title</title></head> <body> <?php if (!$someCondition){ die(); } else{ #Do something } ?> </body> <html>
I hope the purpose of this code is straightforward. If a certain condition is met (ie can’t connect to database), then the program should die, but otherwise it should execute. My problem arises when the die() function is executed. It stops right there, and sends only the first three lines to the browser, but not the last two lines.
Is there a funciton that I can use instead of die() so that the php chunks will stop executing, but the static HTML text is still sent through?
You should be separating out your header and footer into an separate files and functions. This makes the UI much easier to maintain and keeps things consistent for rendering the view. Couple that with using Exception handling and you’re golden.