note 98877 deleted from function.fopen by danbrown

From: Date: Tue, 13 Jul 2010 16:02:12 +0000
Subject: note 98877 deleted from function.fopen by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-170878@lists.php.net to get a copy of this message
Note Submitter: Anonymous ---- Regarding the post under. Using his/her function would be fine in some cases, how ever PHP does enable the option to turn off http fopen. Here is the "improved" function. <?php function http_file_exists( $url ) { if( ini_get( "allow_url_fopen" ) == 1 ) { $fh = fopen( $url, "r" ); if( $fh ) { fclose( $fh ); return true; } return false; } trigger_error( "allow_url_fopen is turned off!", E_USER_WARNING ); return false; } ?> Of course you can use ini_set( "allow_url_fopen", 1 ) if you are allowed to you can use fsockopen and check the response for the 404 header, you can also use cURL and check for the 404 header. To keep the function small I left both out.

« previous php.notes (#170878) next »