I am trying to format the user's website. The If and Else Statements work, but the Else if Statements do not work. What am I doing wrong? Thank you. I appreciate your help.
$website = formatWebsite(($_POST['website']));
function formatWebsite($website)
{
//Checks to see if website has security
$scheme = substr($website, 0, 9);
if ($scheme = "https://www")
{
$scheme = substr($website, 0, 7);
return $website;
}
elseif($scheme = "https://")
{
$formattedWebsite = "https://www". trim($website, "https://");
$scheme = substr($website, 0, 6);
return $formattedWebsite;
}
//Removes http:// from user's website
elseif ($scheme = "http://")
{
$formattedWebsite = trim($website, "http://");
$scheme = substr($website, 0, 2);
return $formattedWebsite;
}
//Makes sure www. is in the user's website
elseif ($scheme != "www")
{
$formattedWebsite = "www.". $website;
return $formattedWebsite;
}
//If the user's website has www. print the websites
else
{
return $website;
}
}
Aucun commentaire:
Enregistrer un commentaire