Oracle Database MySQL 5.6 Developer — Question 36
Identity two ways to configure a PHP application to use the UTF8 character set.
Answer options
- A. mysqli: :query (‘’SET NAMES utfs’’);
- B. mysqli : :set_charset (‘utf8’)
- C. spdo = new PDO (‘’mysql:host=localhost;dbname=test;charset=utfs’’, user’’, ‘’pass’’);
- D. PDO: :set_charset(‘’utf8’’)
Correct answer: B
Explanation
The correct answer is B because using mysqli::set_charset('utf8') explicitly sets the character set for the MySQLi connection to UTF-8. Option A is incorrect due to a typo in 'utfs' instead of 'utf8', while options C and D incorrectly implement PDO syntax and also contain the same 'utfs' typo in option C.