if($url) {//Url değişkeni doluysa
kodlar
} else {
boşsa kodlar
}

Bu Şekilde Fonksiyon oluşturmalısın