PDO connection : UTF-8 declaration with SET NAMES / CHARACTER SET?
Setting it in DSN is the only proper way (although it is only supported since 5.3).
You can this one and SET NAMES
at the same time.
All the other ways will make infamous half-fictional GBK injection possible.
Please note that your setting for error_reporting() is utterly wrong. it have to be unconditional -1.
If you concerned about displaying errors - there is a proper ini setting for this, called display_errors
, can be set at runtime.
While error_reporting sets level of the error and should be at max all the time.