Can i use this statement?
<?php
$file = 'example.txt';
$newfile = 'example.txt.bak';
if (!copy($file, $newfile)) {
echo "failed to copy $file...\n";
}
?>
Now instead of example.txt
can i use "http://engine.searchr.us/web-search.phtml?search=TEST+SEARCH"
?
Is it possi开发者_C百科ble ?
Yes you can, as long as allow_url_fopen is enabled in your PHP config.
Yes, it is possible. As the manual says:
Both source and dest may now be URLs if the "fopen wrappers" have been enabled. See fopen() for more details.
You can read remote files using PHP
$contents = '';
$file = fopen ("http://www.example.com/", "r");
if (!$file) {
echo "<p>Unable to open remote file.\n";
exit;
}
while (!feof ($file)) {
$line = fgets ($file, 1024);
$contents .= $line;
}
fclose($file);
echo $contents;
Source
http://php.net/manual/en/features.remote-files.php
As Emil Vikström said you must have allow_url_fopen directive enabled. Documentation also says that this directive can be set only into php.ini
file.
精彩评论