$file = 'example.txt'; if(fileExists($file)){ echo "File exists!"; } else { echo "File not found!"; }
$image = 'image.jpg'; if(fileExists($image)){ echo "Image exists!"; } else { echo "Image not found!"; }This code checks if the image file "image.jpg" exists on the server. If it does, then it prints "Image exists!" otherwise, it prints "Image not found!". Package Library: The fileExists function is a built-in function in PHP, and it does not require any external package or library. It is available in all PHP versions, and can be used in any PHP application without any additional installation or configuration.