PHP:从网页获取file_get_contents比较


PHP, Get file_get_contents from webpage & compare

我得到一个错误:

<?php
$homepage = file_get_contents('http://segeco.me/lol.txt');
if ($homepage == ('loll')) then
echo $homepage;
?>

ERROR: Parse ERROR: syntax ERROR, unexpected 'echo' (T_ECHO) in/home/blusnow/public_html/dog.php第5行

(代码不是php,只是一个例子)

您的错误在if($homepage== ('loll')) then

你应该这样做:

if($a == $b){
echo $a;
}
else{
echo "nope...";
}

完整的示例:

$first = file_get_contents('http://www.example.com');
$second = file_get_contents('http://www.wikipedia.org');
if($first == $second){
echo $first;
}

else{
    echo $second;
}