$url = "https://www.example.com"; if (get_headers($url, 1)['Content-Type'] === 'text/html') { echo "URL exists"; } else { echo "URL does not exist"; }
$file = "example.txt"; if (file_exists($file)) { echo "File exists"; } else { echo "File does not exist"; }This example checks whether a file named "example.txt" exists or not using the file_exists() function. Package/library: This code does not use any specific package or library.