Is there a recommended way to handle the display of shortened text with a link to the full content in PHP?

When displaying shortened text with a link to the full content in PHP, one recommended way to handle this is by truncating the text to a certain length and then adding a "Read more" link that redirects to the full content. This can be achieved by using functions like substr() to limit the text length and concatenating the "Read more" link at the end.

<?php
$text = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.";

$maxLength = 50;
if (strlen($text) > $maxLength) {
    $shortText = substr($text, 0, $maxLength) . "... <a href='full_content.php'>Read more</a>";
} else {
    $shortText = $text;
}

echo $shortText;
?>