+ 3

Php exception handling

So i was trying to advance my knowledge on php and i came across the php exception handling tutorial on w3schools but am not convinced on why php needs it when u can just use if else statement to check for errors and handle it, would like anyone that actually uses php exception handling in real life code implementation to help me understand the need for it, Thanks.

3rd Apr 2018, 12:11 PM
Ayodele Abigail Oluwabunmi
Ayodele Abigail Oluwabunmi - avatar
2 odpowiedzi
+ 1
exception handling saves you from unforseen bugs. usually, if-else caters for what the programmer expects might occur.
7th Apr 2018, 12:50 PM
Adorable
Adorable - avatar
0
Throw and catch blocks in php are better for handling errors specifically. That's what they're for. Using if else statements in some situations can be clumsy and bulky for your code.
4th Apr 2018, 10:39 AM
Bukola Bisuga
Bukola Bisuga - avatar