What potential pitfalls should be considered when storing source code with indentation in a database using PHP?

When storing source code with indentation in a database using PHP, a potential pitfall to consider is that the indentation may be lost or altered when retrieving the code from the database. To solve this issue, you can use PHP's htmlspecialchars() function to encode the source code before storing it in the database and then use htmlspecialchars_decode() when retrieving the code to ensure that the indentation is preserved.

// Encode the source code before storing it in the database
$encoded_code = htmlspecialchars($source_code);

// Store the encoded code in the database

// Retrieve the encoded code from the database
$encoded_code_from_db = "retrieve code from database";

// Decode the encoded code to preserve the indentation
$decoded_code = htmlspecialchars_decode($encoded_code_from_db);

// Use $decoded_code for displaying or processing the source code