0

Why I get null output from this code? But when I change url become hxxp://football-replay.com I get output 0.

<?php
  class PR {
 public function get_google_pagerank($url) {
 $query="http://toolbarqueries.google.com/tbr?client=navclient-auto&ch=".$this->CheckHash($this->HashURL($url)). "&features=Rank&q=info:".$url."&num=100&filter=0";
 $data=file_get_contents($query);
 $pos = strpos($data, "Rank_");
 if($pos === false){} else{
 $pagerank = substr($data, $pos + 9);
 return $pagerank;
 }
 }

bla bla bla

$url='advertcn.org';
$pr = new PR();
echo "$url has Google PageRank: ". $pr->get_google_pagerank($url) ;
?>

1 Answers1

0

If you look very closely, you can see an if statement at the end of the function. It conditionally returns a value, but only if $data contains the string 'Rank_'. So my educated guess would be that for one of the urls you get a response containing that string, and for the other one you don't.

GolezTrol
  • 114,394
  • 18
  • 182
  • 210