How can PHP functions like substr be utilized to create teaser texts and full news texts in a professional and user-friendly manner?
To create teaser texts and full news texts in a professional and user-friendly manner using PHP functions like substr, you can extract a portion of the full text to display as a teaser and provide a "Read more" link to the full text. This allows users to get a preview of the news content before deciding to read the entire article.
<?php
$fullText = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.";
$teaserText = substr($fullText, 0, 100) . "...";
$fullNewsText = $fullText;
echo "<h3>Teaser:</h3>";
echo "<p>$teaserText</p>";
echo "<h3>Full News:</h3>";
echo "<p>$fullNewsText</p>";
echo "<a href='#'>Read more</a>";
?>