I have a function named categories_name()
which is given below:
function categories_name(){
if($GLOBALS["pro_cat"] == "1"){
$name_cat = "<a href='category.php cat_id=".$GLOBALS["pro_cat"]."'>Laptops</a>";
}else if($GLOBALS["pro_cat"] == "2"){
$name_cat = "<a href='category.php?cat_id=".$GLOBALS["pro_cat"]."'>Tablets</a>";
}else if($GLOBALS["pro_cat"] == "3"){
$name_cat = "<a href='category.php?cat_id=".$GLOBALS["pro_cat"]."'>Mobile Phones</a>";
}else{
echo "Not defined";
}
return $name_cat;
}
It basically returns the value of $name_cat
.
But when I run this program I get this error:
Undefined variable: name_cat on line 2
Which supposed to be this:
return $name_cat;