Check whether a php code exists in the remote file
/**
- Php checks whether remote files exist
- By http://bbs.it-home.org
- */
- Function get_http_response_code ($ theURL ){
- $ Headers = get_headers ($ theURL );
- Return substr ($ headers [0], 9, 3 );
- }
/**
- * Fetches all the real headers sent by the server in response to a HTTP request without redirects
- * Obtain a header that does not contain redirection.
- */
- Function get_real_headers ($ url, $ format = 0, $ follow_redirect = 0 ){
- If (! $ Follow_redirect ){
- // Set new default options
- $ Opts = array ('http' =>
- Array ('max _ redirects' => 1, 'Ignore _ errors '=> 1)
- );
- Stream_context_get_default ($ opts );
- }
- // Get headers
- $ Headers = get_headers ($ url, $ format );
- // Restore default options
- If (isset ($ opts )){
- $ Opts = array ('http' =>
- Array ('max _ redirects' => 20, 'Ignore _ errors '=> 0)
- );
- Stream_context_get_default ($ opts );
- }
- // Return
- Return $ headers;
- }
- ?>
For how to determine the curl method, refer to: php code that uses curl to determine whether a remote file exists. |