PHP,从网页获取file_get_contents&相比

时间:2015-10-20 16:24:09

标签: php

我收到了错误:

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

错误:解析错误:语法错误,意外错误&#39;回声&#39; (T_ECHO)在第5行的/home/bluesnow/public_html/dog.php

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

1 个答案:

答案 0 :(得分:0)

您的错误位于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;
}