<?php

$var1 = "abc";
$var2 = "";
$var3 = "def";

echo implode(', ', array_filter([$var1, $var2, $var3]));