[英]php process xml readfile
Here https://stackoverflow.com/a/3673989/2118559 read that to get xml content better to use readfile
, because it is the fastest. 在这里https://stackoverflow.com/a/3673989/2118559阅读该内容,以便更好地使用readfile
获得xml内容,因为它是最快的。
I want to get and process content from here http://api.stopforumspam.org/api?ip=91.186.18.61 我想从这里获取并处理内容http://api.stopforumspam.org/api?ip=91.186.18.61
I did 我做了
readfile( "http://api.stopforumspam.org/api?ip=91.186.18.61" );
Then if result contains word no
I will continue. 然后,如果结果中包含单词no
我将继续。
Like 喜欢
if( strpos(
readfile( "http://api.stopforumspam.org/api?ip=". urlencode(get_ip_address()) ),'no'
) === true ){
echo ' continue<br>';
}
But it does not work. 但这行不通。 As understand readfile
as if echo
content of the file. 如了解readfile
一样, echo
显文件的内容。
Do I need to use file_get_contents
(can not do it with readfile
)? 我是否需要使用file_get_contents
(不能使用readfile
做到)?
Edited 编辑
In above example I used wrong condition. 在上面的示例中,我使用了错误的条件。 Need for example !== false
. 需要例如!== false
。
But remains problem that such code 但是这样的代码仍然存在问题
readfile( "http://api.stopforumspam.org/api?ip=91.186.18.61" );
echo in my website content of xml file. 在我的xml文件的网站内容中回显。 like ip yes 2013-10-07 13:19:05 2
像ip yes 2013-10-07 13:19:05 2
Do not need to echo (do not need to show visitor, that his ip address is in spam list or no) 不需要回显(不需要向访问者显示,他的IP地址在垃圾邮件列表中还是没有)
use file_get_contents
and !==false
使用file_get_contents
和!==false
try this 尝试这个
if( strpos(file_get_contents("http://api.stopforumspam.org/api?ip=". urlencode(get_ip_address()) ),'no') !== false ){
echo ' continue<br>';
}
You should use file_get_content 您应该使用file_get_content
$data = file_get_contents("http://www.stopforumspam.com/api?ip=91.186.18.61");
$chk = strpos($data, 'yes');
if($chk === false)
{
echo ' continue<br>';
}
I have checked the code its working. 我已经检查了代码的工作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.