例如,我想知道这些文件是否存在.
http://www.stackoverflow.com/favicon.ico
http://www.stackoverflow.com/reset.css
Run Code Online (Sandbox Code Playgroud)
然后下载它(如果显然是exixts).
<?php
if( ( $file = file_get_contents( 'http://www.stackoverflow.com/favicon.ico' ) ) ) {
echo "file exists.";
file_put_contents( 'favicon.ico', $file );
}
else {
echo "File does not exist.";
}
Run Code Online (Sandbox Code Playgroud)