Bd779de8a3e7524c5e4c21f2940545fd

Hello coders,

I'll share you a new script that can be used in projects to get information about a website like www.denizlikizyurdu.com

You can easily use and share it.

Also waiting for your refactorings.

Best wishes.

<?php

/* Write your header.. */
header("Content-Type: text/html; charset=utf-8");

/* Functions Starts */
function myFunc($URL){
  $myFunc= get_meta_tags($URL);
  return $myFunc;
}
$URL = "http://www.refactormycode.com";

$_myFunc= myFunc($URL);
	/* PRint it out... */
	 echo "$URL <p>";
	 echo $_myFunc["author"]."<p>";   
  	 echo $_myFunc["keywords"]."<p>";    
  	 echo $_myFunc["description"]."<p>"; 
 	 echo $_myFunc["robots"]."<p>";

?>

Refactorings

No refactoring yet !

E96a421d76c1fc107a5d291c6999b2ef

Alex

August 31, 2010, August 31, 2010 07:25, permalink

No rating. Login to rate!

I don't see any reason for wrapping the native PHP function. The native function does all the work, just use it by itself. The function and variable names are also of a poor choice.

95cc5ff445269665f06bc47b771c558f

Thomas

September 5, 2010, September 05, 2010 22:28, permalink

No rating. Login to rate!
get_meta_tags($URL);
Dc8c9c80cb4deda4e8ca151429c39dcd

nielsenaa

October 21, 2010, October 21, 2010 01:15, permalink

No rating. Login to rate!

No offense, but i fully Agree with Alex ;

The native function does the same ;

Even maybe, if you have thousands of urls to process, you should consider doing the opposite, wrapping your echos in a single function

Ed75ffe75388a64cfaca3df3c4f14f68

Zurahn

November 13, 2010, November 13, 2010 04:12, permalink

No rating. Login to rate!

The pointless wrapping has already been mentioned, but you can better organize your echos into one statement. Multiple echos are also technically less efficient than concatenating first (though unless you're doing an obscene amount of outputs it's going to be negligible).

echo <<<OUT
    <p>{$URL}</p>
    <p>{$_myFunc["author"]}</p>   
    <p>{$_myFunc["keywords"]}</p>    
    <p>{$_myFunc["description"]}</p> 
    <p>{$_myFunc["robots"]}</p>
OUT;

Your refactoring





Format Copy from initial code

or Cancel