How to Handle Errors in PHP
PHP has several types of error messages. These include errors, notices and warnings. Errors are caused by faults in your code that will cause the script to stop executing, notices indicate that your code may have problems and warnings are non-fatal messages that do not halt execution of the script.
Many string functions in PHP have an option to let you specify the character encoding you’re working with (and some do so by default, including mb_strlen(), is_soap_fault(), and htmlentities()). Using these instead of standard string functions helps you avoid having your Unicode strings mangled later by other functions that don’t understand your encoding.
Most modern PHP applications use a database to store and retrieve data. There are a few ways to connect and interact with your database, and the choice of which one you choose depends on your application, your framework and other factors.
This article will give an overview of some of the major options available, highlight some advantages and disadvantages and provide examples on how to use them. The aim is to help new PHP developers learn about the options and perhaps inspire seasoned pros to reconsider what they’ve been doing for years.
Information can be passed to PHP functions through arguments. When you call a function, it will run with these parameters as its inputs and outputs. PHP also has special error handling features that can be enabled in your code by using the Error Control Operator @. By placing the @ sign at the beginning of an expression, you can tell PHP that any errors that are directly a result of this expression should be suppressed and not displayed or reported.