PHP,从网页获取文件内容&;比较
我在这方面遇到了一个错误:PHP,从网页获取文件内容&;比较,php,Php,我在这方面遇到了一个错误: <?php $homepage = file_get_contents('http://segeco.me/lol.txt'); if ($homepage == ('loll')) then echo $homepage; ?> 错误:解析错误:语法错误,第5行的/home/bluesnow/public\u html/dog.php中出现意外的“echo”(T_echo) (代码不是php,只是一个例子。)您的错误在如果($homepage==(
<?php
$homepage = file_get_contents('http://segeco.me/lol.txt');
if ($homepage == ('loll')) then
echo $homepage;
?>
错误:解析错误:语法错误,第5行的/home/bluesnow/public\u html/dog.php中出现意外的“echo”(T_echo)
(代码不是php,只是一个例子。)您的错误在如果($homepage==('loll'))那么
你应该做:
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;
}
另外,如何从internet获取该文件?例如,我想从dropbox获取一个txt。file\u get\u contents()
只返回一个字符串。检查文档:是否有任何错误??更新了问题:)