What is the impact of storing text in a database on formatting in PHP?
When storing text in a database in PHP, the formatting of the text can be affected by the way it is stored and retrieved. To preserve formatting, you can use PHP's htmlspecialchars function to encode special characters before storing the text in the database, and then use htmlspecialchars_decode function to decode the text when retrieving it.
// Storing text in the database
$text = "<h1>Hello, World!</h1>";
$encoded_text = htmlspecialchars($text);
// Store $encoded_text in the database
// Retrieving text from the database
// Retrieve $encoded_text from the database
$decoded_text = htmlspecialchars_decode($encoded_text);
echo $decoded_text;