2011-10-23 191 views
1

这是非常基本的,我敢肯定,但我没有使用过PHP,因此发现它很难,我使用的代码给了我一个错误,我不确定我能做什么解决它PHP代码中的错误

<?php 
$query = 'dogs'; 
$searches = 100; // number of results 
$start = 0; 
$pos = 1; 
while($start < $searches) 
    { 
    $data = getPage('http://www.google.com/search?start=' . $start . '&q=' . urlencode($query)); 
    preg_match_all("/\<li class\=g\>\<h3 class\=\"r\"\>\<a href\=\"([^\<\>]*)\" class\=l\>/",$data,$matches); 
    for($x = 0; $x < count($matches[1]); $x++) 
     { 
     echo '<p>' . $pos . ' ' . ($matches[1][$x]) . '</p>'; 
     $pos++; 
     } 
    $start += 10; 
    } 
?> 

错误: 呼叫到第11行

任何帮助未定义功能GETPAGE()?

+0

你有'getPage()'定义的任何地方吗?它是否在您忘记包含的另一个文件中? – PureForm

回答

0

您的代码和PHP中没有getPage();函数。你必须有一个才能打电话/使用它。

请参阅file_get_contents(); | fopen();

+0

谢谢你,会努力使它更进一步 – anonuser0428

5

PHP中没有“getPage”函数(除非您定义了它)。

它看起来像功能file_get_contents()是你的目的。

+0

你是最快的手指比赛的胜利者。 :) – jsleuth

+0

谢谢,会尽量让它进一步工作 – anonuser0428

2

getPage()函数被定义在别的地方,你不包括在内?

我的猜测是你想用file_get_contents()代替。

+0

谢谢,会尽量让它进一步工作 – anonuser0428