How can PHP be used to create a clickable link within a text area, such as a guestbook entry?

To create a clickable link within a text area in PHP, you can use the `nl2br()` function to convert newlines to HTML line breaks and then use the `preg_replace()` function to detect URLs within the text and turn them into clickable links. This allows users to input URLs in a text area and have them automatically converted into clickable links when displayed.

<?php
function makeClickableLinks($text) {
    $text = nl2br($text);
    $text = preg_replace('/(https?:\/\/[^\s]+)/', '<a href="$1" target="_blank">$1</a>', $text);
    return $text;
}

// Example usage
$text = "Check out this website: https://www.example.com";
echo makeClickableLinks($text);
?>