Is there a function that only kills the rest of the php scripting, but not html scripting that is not included in any php arguments?
[RESOLVED] die() or exit() Alternative
Not really, since PHP doesn't differentiate between the two. A better approach would probably be to re-work the logic/flow of the script.
No, return just ends the current function, I was hoping there was one that acted like the die function, but only to php because of I have my page set up where the content is in the middle of a table, so if I use the die function the page becomes all deformed. I've been using a if/else statement where the contents of the page are all located in the else section, but it turns a little into a hassle when there's more then one thing I'm checking for before the contents of the page will be displayed. Hoping to simplify my life, that's all lol.
I know what it does, but you have so little information i thought the guess was worth a shot.
I guess we need to know why you're calling die(), then ... if there's an error condition, but there's still output to send to the browser, then the error must not be that important?
You might consider just setting up some kind of error container variable, adding the relevant description to it at the point where you are currently calling die(), and finishing your output, after which you could barf up all the errors at the bottom of the page.
No not for error handling, There are two reasons, the first was on included pages, I set a variable on the host page, and checked to see if the variable was set on the included page in case anyone tried opening just that page, and the second was a double check on admin pages to make sure the user had administrative rights.
What are the admin rights necessary for? Editing something, or viewing the page? If you're not allowed to even view the page without admin rights, I'd use header() to redirect the page someplace else immediately. . . not die(). Authorization checks should go way up in the script.
Same with the "referrer" type issue. If they aren't coming from where you want, redirect them, or show an error message and call exit()/die(). You don't need to show them anything at that point other than, "don't do this please."
You want to show us some code? Maybe we could quit grasping at straws, then...
For the administration rights, its for viewing pages to edit users and so on. I have a session variable for the usertype, and for the validation it double checks that the usertype is admin. As for setting it in the header, that's not possible for this particular site. The layout of the site is very code intensive with html, so to save on files size, I set it up to where the only file that has all the html in it is the index.php file, and the main content area of the page is blank, and filled with includes. I have a table in my database that has the page names for the $_GET['page'] variable, and file locations. So I escape the variable, then check the table in the db to see what file to load. So long story short, all php is in the middle of the index.php page, therefore I cant do a 301 redirect.
So, are we back to what Brad said originally?
bradgrafelman;10968871 wrote:Not really, since PHP doesn't differentiate between the two. A better approach would probably be to re-work the logic/flow of the script.
Well, seems like it lol.