Hello in this video we are going to take a look at the die function for error handling. So if for example trying to do something like check if a file exists from say something if the file doesn't exist unless if on the school list and I'm going to put a fall there are no doesn't exist. I'm gonna put simple dot XML I know days in a fall day course in paradise now. And I would put let's say echo. Yeah. Yes.
And let's get some echo here as well. All the code where the rest of the code would go. If I run that, yet the rest of the code because this does not exist, but what if this is dependent on On what has come before it, and what we can do say else, if this condition is false, it was put dye and dye basically prevents the rest of the application from running, you could put dye like this and the rest of the application won't run or you can make something a bit more meaningful per message in here. And this will just basically echo this out as well. And for this I'm just going to per file not the file to can you mention Mark and I will also put So, as you can see some form of family fault continue, because this you know, equates to false.
The L statement is triggered and it says die for now fine. So, Princess as soon as it hits the DI command, anything after is doesn't get run. So, that's great. Especially If you're you know, testing stuff to make sure things are loading correctly or you know, certain functionalities working really, if it isn't, you can just put die and be like, okay, the rest of the page haven't loaded. So it needs to be roughly here where the problem lies. So yeah, that's it.
That's the die function. If you have any questions, feel free to pop me a message. And as usual, I look forward to seeing you in the next awesome PHP video.