Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

StarTutorial.com:
Modern PHP Developer - Exception
Oct 30, 2018 @ 18:49:38

The StarTutorial site has posted the latest in their "Modern PHP Developer" series of posts outlining some of the more recent changes to PHP and its ecosystem that can help you become a better developer. In this latest post they focus on Exceptions in PHP - the types, handling them and when they're most useful.

Since PHP 5 was released, Exception is added to PHP as an object-oriented programming language feature. By definition, an Exception is an exceptional event during program execution. In PHP, an Exception is simply an object (an instance of Exception class). When an exception occurs, PHP will halt current execution flow and look for an handler, and then it will continue its execution by the handler's code. If no handler is found, a PHP Fatal Error will be issued with an "Uncaught Exception ..." message and the program terminates.

The tutorial is then broken down into several parts:

  • When to use Exception
  • How to use Exception
  • Create your first custom exception 5.3
  • SPL exceptions
  • RuntimeException

For each item in the list, there's a summary of the topic and code examples to help illustrate the points made.

tagged: tutorial modern developer exceptions series

Link: https://www.startutorial.com/articles/view/modern-php-developer-exception


Trending Topics: