What are exceptions and how to handle them?
Exception handling is an elegant way to handle errors which are beyond the program’s scope. Click : https://phpgurukul.com/what-are-exceptions-and-how-to-handle-them/ In this tutorial, we are going to learn how and when to use exception handling and, even more important, when not to use it. In order to explain the need for exception handling, we will try to see what happens when a program is fed with faulty data. In our example, we will develop the class FuelEconomy that calculates with the method calculate() the fuel efficiency of cars by dividing the distance traveled by the gas consumption. class FuelEconomy { // Calculate the fuel efficiency public function calculate ( $ distance , $ gas ) { return $ distance / $ gas ; } } We will feed the class with the nested array $dataFromCars, in which each nested array has two values: the first value is for the distance traveled and the second value is for the gas consumption. While the first and last nested arrays contain legitima...