What is the purpose of setting the PDO fetch mode to FETCH_OBJ in the provided PHP code?

Setting the PDO fetch mode to FETCH_OBJ in the provided PHP code allows the fetched data from the database to be returned as objects rather than arrays. This can make the code more readable and easier to work with, as you can access the data using object properties instead of array keys.

// Set the PDO fetch mode to FETCH_OBJ
$pdo->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_OBJ);