3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $url = 'http://cmps.cz/i/nar/YT-1954.jpg'; function GetRemoteLastModified( $uri ) { // default $unixtime = 0; $fp = fopen( $uri, "r" ); if( !$fp ) {return;} $MetaData = stream_get_meta_data( $fp ); foreach( $MetaData['wrapper_data'] as $response ) { // case: redirection if( substr( strtolower($response), 0, 10 ) == 'location: ' ) { $newUri = substr( $response, 10 ); fclose( $fp ); return GetRemoteLastModified( $newUri ); } // case: last-modified elseif( substr( strtolower($response), 0, 15 ) == 'last-modified: ' ) { $unixtime = strtotime( substr($response, 15) ); break; } } fclose( $fp ); return $unixtime; } var_dump(GetRemoteLastModified('http://cmps.cz/i/nar/YT-1954.jpg'));
based on l3qWL
Output for 5.3.21 - 5.4.45, 5.5.33, 5.6.18 - 5.6.19, 7.0.4, 7.0.20, 7.1.5 - 7.2.0
Warning: fopen(): php_network_getaddresses: getaddrinfo failed: System error in /in/qbGgE on line 10 Warning: fopen(http://cmps.cz/i/nar/YT-1954.jpg): failed to open stream: php_network_getaddresses: getaddrinfo failed: System error in /in/qbGgE on line 10 NULL
Output for 5.5.24 - 5.5.32, 5.5.34 - 5.6.17, 5.6.20 - 7.0.3, 7.0.5 - 7.0.6, 7.1.0
Warning: fopen(): php_network_getaddresses: getaddrinfo failed: Name or service not known in /in/qbGgE on line 10 Warning: fopen(http://cmps.cz/i/nar/YT-1954.jpg): failed to open stream: php_network_getaddresses: getaddrinfo failed: Name or service not known in /in/qbGgE on line 10 NULL