I first send a term to a webpage outside my site. Then that page returns only text. I want to take that text and process it? So I'll have to get that text on my server for that right? So how can i do it开发者_如何学C? or is there any other option?
by using file_get_contents()
Use cURL or file_get_contents() if your server has the URL wrappers enabled.
Below is the code to read remote file using PHP
if ($fp = fopen('http://www.google.com/', 'r')) {
$content = '';
while ($line = fread($fp, 1024)) {
$content .= $line;
}
} else {
// an error occured when trying to open the specified url
}
Make sure you have 'allow_url_fopen' set to 1 in your php.ini
精彩评论