Web page classification

Sir,

Thank u for your reply.sir i want to classify the web page by using URL features namely 1.abbreviation.abbreviation in URL,2.abbreviations in slash of URL,3.Number of abbreviations in URL…so that s y i attached my coding i going to classify the web page like sports,education,etc by using URL features.i used explode function for split the above URL abbreviation features and used switch case for string comparison but i ll expect category value like 0,1,2… for each category.but it doesn’t work.

<?php
echo “Enter the url”;
echo “<input type=text name=‘t’ value=‘$t1’>”;
$t1=$_GET[‘$url’];
echo “<form method=post action=getdomain($t1)>”;

function getdomain($url)
{
$explode = explode(“.”, $url);
$tld = $explode[2];
$tld = explode(“/”, $tld);
$x = $explode[1];
return $x;
}

string y[7]={‘arts’,‘sports’,‘finance’}
for(i=0;i<=3;i++)
{
b=strcmp($x,$y[i])
if(b==0)
{
c=y[i];
}
else
{
return “invalid”;
}
}

switch ($c)
{
case “arts”:
return att1=0;
break;
case “sports”:
return att1=1;
break;
case “finance”:
return att1=2;
break;

}
?>

For output i created form by using label and text box.suppose if i enters the URL name for example WWW.yahoo sports.com means i expecting the sports category value in switch case that is 2.

I think you need to learn PHP first before attempting to do something like this. I fixed all you syntax as well as logic errors:

<?php
   echo "Enter the url";
   $t1=$_GET['url'];
   echo "<form method=post action=".getdomain($t1).">";
   echo "<input type=text name='t' value='$t1'>";

   function getdomain($url)
   {
	   $explode = explode(".", $url);
	   $tld = $explode[2];
	   $tld = explode("/", $tld);
	   $x = $explode[1];
	   return $x;
   }

   $y[7]= array("arts","sports","finance");
   for($i=0;$i<=3;$i++)
   {
	   $b=strcmp($x,$y[$i]);
	   if($b==0)
	   {
		   $c=$y[$i];
	   }
	   else
	   {
		   return "invalid";
	   }
   }

   switch ($c)
   {
	   case "arts":
		   return $att1=0;
		   break;
	   case "sports":
		   return $att1=1;
		   break;
	   case "finance":
		   return $att1=2;
		   break;

   }
?>

Note that the above only fixes syntax but not all the logic.