Errors Intro - PHP - P72

Published: 16 July 2020
on channel: Dino Cajic
174
7

Before we start looking at ways to handle errors in PHP, I wanted to touch on a few topics that beginner programmers tend to get confused. Bugs are normally errors in code that the programmer coded, that produce a result, and that result is not correct. For example, let’s say that we were creating a power function. If we sent two arguments to the power function, like 2 and 3, we might expect that the power function will raise 2 to the power of 3. If you get 8, the function performed as was intended. If you get something other than 8, for example, 23, the function has a bug. This type of bug is referred to as a semantical error. The code passes compilation, or interpretation, and it functions, but produces the wrong result. A bug can also be catastrophic, that terminates a program, like forgetting a semi-colon. This type of error is called a syntax error. It will not pass compilation, or interpretation.

An exception may be raised while the code is executing. For example, let’s say that the code is retrieving some data from the database. The server that’s hosting the code loses connection with the database server because of a power failure. There’s no issue with the code. It’s a power failure. So an exception is thrown. Those exceptions can be caught and handled.

Those exceptions don’t have to be something as catastrophic as a power failure. You can specify that the function must accept only positive integer values. If a negative number is passed, an exception can be raised and handled.

In the next video, we’ll be looking at how to raise and handle these errors.

Read the full article on my website
https://www.dinocajic.com/php-errors-...

Full Code
https://github.com/dinocajic/php-7-yo...

PHP Playlist
   • PHP Tutorial  

--
Dino Cajic
Author and Head of IT

Homepage: https://www.dinocajic.com
GitHub: https://github.com/dinocajic
Medium:   / dinocajic  
Instagram:   / think.dino  
LinkedIn:   / dinocajic  
Twitter:   / dino_cajic  

My Books
An Illustrative Introduction to Algorithms
https://www.amazon.com/dp/1686863268

Laravel Excel: Using Laravel to Import Data
https://amzn.to/4925ylw

Code Along With Me - PHP: From Basic to Advanced PHP Techniques
https://amzn.to/3M6tlGN


On this page of the site you can watch the video online Errors Intro - PHP - P72 with a duration of hours minute second in good quality, which was uploaded by the user Dino Cajic 16 July 2020, share the link with friends and acquaintances, this video has already been watched 174 times on youtube and it was liked by 7 viewers. Enjoy your viewing!