Are there any best practices for creating aesthetically pleasing yet secure unique strings in PHP for use in URLs?

When creating unique strings for use in URLs in PHP, it is important to balance security and aesthetics. One common approach is to generate a random string using a combination of alphanumeric characters and symbols, ensuring uniqueness by checking against existing strings. Additionally, encoding the generated string using base64 or hashing algorithms can further enhance security.

function generateUniqueString($length = 10) {
    $characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!@#$%^&*';
    $randomString = '';
    
    do {
        for ($i = 0; $i < $length; $i++) {
            $randomString .= $characters[rand(0, strlen($characters) - 1)];
        }
    } while (isExistingString($randomString));
    
    return $randomString;
}

function isExistingString($string) {
    // Check if the generated string already exists in the database or any other storage
    // Return true if it exists, false otherwise
}