Here https://stackoverflow.com/a/3673989/2118559 read that to get xml content better to use readfile
, because it is the fastest.
I want to get and process content from here 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.
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.
Do I need to use file_get_contents
(can not do it with readfile
)?
Edited
In above example I used wrong condition. Need for example !== 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. like 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)
use file_get_contents
and !==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
$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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.