What are some common methods for enclosing a selected text in HTML tags using PHP?

When working with PHP, it is common to need to enclose a selected text within HTML tags. One way to achieve this is by using string concatenation to add the opening and closing tags around the selected text. Another method is to use PHP's built-in functions like `sprintf()` to format the text with the desired HTML tags.

// Method 1: Using string concatenation
$selectedText = "Hello, world!";
$enclosedText = "<div>" . $selectedText . "</div>";
echo $enclosedText;

// Method 2: Using sprintf()
$selectedText = "Hello, world!";
$enclosedText = sprintf("<div>%s</div>", $selectedText);
echo $enclosedText;