SORU
4 Mayıs 2010, Salı


Nasıl olursa http://'in eklemek için URL var değil mi?

http:// Bir değil eğer yok http:// url Ekle veya https:// ftp:// ?

Örnek:

addhttp("google.com"); // http://google.com
addhttp("www.google.com"); // http://www.google.com
addhttp("google.com"); // http://google.com
addhttp("ftp://google.com"); // ftp://google.com
addhttp("https://google.com"); // https://google.com
addhttp("http://google.com"); // http://google.com
addhttp("rubbish"); // http://rubbish

CEVAP
5 ŞUBAT 2013, Salı


Yazma zamanda, cevapların hiçbiri yerleşik bu fonksiyonu kullanılmış

function addScheme($url, $scheme = 'http://')
{
  return parse_url($url, PHP_URL_SCHEME) === null ?
    $scheme . $url : $url;
}

echo addScheme('google.com'); // "http://google.com"
echo addScheme('https://google.com'); // "https://google.com"

Ayrıca bakınız: parse_url()

Bunu Paylaş:
  • Google+
  • E-Posta
Etiketler:

YORUMLAR

SPONSOR VİDEO

Rastgele Yazarlar

  • CruzerLite

    CruzerLite

    1 EKİM 2011
  • Music EuroDance 2

    Music EuroDa

    12 Mayıs 2011
  • Stevie

    Stevie

    2 Mayıs 2010