I'm new to PHP and MySQL, so I read a lot of tutorials and things like that. In most of them, the author stops the script by using the die(); or exit (); function. I've also read that this is a bad way to end a script.
Now I want to code something by myself and I wonder if there is a better way to end a script? Is it better to use trigger_error? And what's the difference to die();? Or should I use a lot of else's and if's to avoid using die() at all?
I've searched a lot on the internet about this but couldn't find a clear answer. Seems like everyone is using just die().
Furthemore, I Know that you can use try/catch with PDO, but at the moment I'm just using mysqli and want to know if there is a better way without using PDO.
I'm very grateful for every meaningful answer!