Avatar

Hello Php Coders,

It'll be useful to get meta information of an site url.

Take a look, you'll like it.

http://www.freemahjonggames1.com

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
<?php
 
// char coding
header("Content-Type: text/html; charset=utf-8");

// get info function
function getInfo($URL){
  $getInfo= get_meta_tags($URL);
  return $getInfo;
}

// write the url below
$URL = "http://www.joyent.com";

// var
$_getInfo = getInfo($URL);
	
         // print
	 echo "$URL <p>";
	 echo $_getInfo["author"]."<p>";   
  	 echo $_getInfo["keywords"]."<p>";    
  	 echo $_getInfo["description"]."<p>"; 
 	 echo $_getInfo["robots"]."<p>";

?>

Refactorings

No refactoring yet !

74002eeb5435bacbda9bf392756d5033

El Barto

July 11, 2010, July 11, 2010 15:08, permalink

No rating. Login to rate!

Well, that's nothing more than a call to a built-in function. Anyway, in the sake of refactoring, you could do something like this.

1
2
3
4
5
6
7
<?php
$url = "http://www.joyent.com";

foreach (get_meta_tags($url) as $tag => $value) {
    echo ucfirst($tag) . ": {$value}\n";
}
?>

Your refactoring





Format Copy from initial code

or Cancel