Publishing System Settings Logout Login Register
Check if config file exists
TutorialCommentsThe AuthorReport Tutorial
Tutorial Avatar
Rating
Add to Favorites
Posted on November 26th, 2008
1595 views
PHP Coding
This simple function will check if a file exists, this could be good to use when you have to include a config file.

<? 
if (!file_exists("config.php")){
    die("Please check that the config file exists and is readable");
}else{
    include ("config.php");
}
?>


In this example i have check if the config file doesnt exist but to check if it does exist then just remove the !

This checks if the file exists, if the file doesnt exist then it will stop executing and display the error message. Although if it does exist then it will carry on and include the file.
Dig this tutorial?
Thank the author by sending him a few P2L credits!

Send
Peter Kelly

Website Development Tutorials Written by Peter Kelly (http://www.peter-kelly.me).
View Full Profile Add as Friend Send PM
Pixel2Life Home Advanced Search Search Tutorial Index Publish Tutorials Community Forums Web Hosting P2L On Facebook P2L On Twitter P2L Feeds Tutorial Index Publish Tutorials Community Forums Web Hosting P2L On Facebook P2L On Twitter P2L Feeds Pixel2life Homepage Submit a Tutorial Publish a Tutorial Join our Forums P2L Marketplace Advertise on P2L P2L Website Hosting Help and FAQ Topsites Link Exchange P2L RSS Feeds P2L Sitemap Contact Us Privacy Statement Legal P2L Facebook Fanpage Follow us on Twitter P2L Studios Portal P2L Website Hosting Back to Top