RE: [PHP-GENERAL] file checking

From: Date: Fri, 23 Jun 2000 18:37:03 +0000
Subject: RE: [PHP-GENERAL] file checking
Groups: php.general 
Request: Send a blank email to php-general+get-2848@lists.php.net to get a copy of this message
Use the is_file function before attempting to open the file. if (is_file("main.php3")){ $fp = fopen("main.php3", "r"); } else { echo "file doesn't exist"; } HTH Chris -----Original Message----- From: Topher [mailto:topher@wcsg.org] Sent: Friday, June 23, 2000 2:49 PM To: php-general@lists.php.net Subject: [PHP-GENERAL] file checking Here's my code: $fp = fopen( "http://media.gospelcom.net/mnn/news/2000/06/44-5min-23-06-2000.mp3", "r"); if ($fp) print "It's there"; } else print "It's not there"; } If the file exists, it works fine, but if it *doesn't* exist, it prints this: Warning: fopen("http://media.gospelcom.net/mnn/news/2000/06/44-5min-23-06-2000.mp3"," r") - Success in /usr/local/www/gospelcom/docs/mnn/mnn/beta/remotetest.php on line 5 It's not there Why is it printing that Warning? I tried is_file and is_readable, and both return that the file isn't not there, regardless of whether it is. :( -- Topher Manager of Internet Services Cornerstone Communications -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net For additional commands, e-mail: php-general-help@lists.php.net To contact the list administrators, e-mail: php-list-admin@lists.php.net

« previous php.general (#2848) next »