What are best practices for handling text content in PHP includes to ensure proper display and formatting on a webpage?

When including text content in PHP includes, it's important to properly handle special characters and formatting to ensure the content displays correctly on the webpage. One way to achieve this is by using the `htmlspecialchars()` function to encode special characters in the text. This function converts characters like <, >, ", ', and & into their respective HTML entities, preventing them from being interpreted as HTML tags or causing formatting issues.

&lt;?php
// Example of including text content in PHP with proper encoding
$text = &quot;This is some &lt;b&gt;bold&lt;/b&gt; text with special characters like &amp; and &lt;&quot;;
echo htmlspecialchars($text);
?&gt;