What are the potential legal implications of faking a URL in PHP for image hosting?

Faking a URL in PHP for image hosting can have legal implications such as copyright infringement if the images being displayed are not owned by the user. To avoid legal issues, it is important to ensure that the images being displayed are either owned by the user or used with proper permission.

// Check if the image URL is valid and owned by the user
$userImageURL = "https://example.com/image.jpg";

if (strpos($userImageURL, "https://example.com/") !== false) {
    // Display the image
    echo "<img src='$userImageURL' alt='User Uploaded Image'>";
} else {
    // Display an error message
    echo "Error: Invalid image URL.";
}