As I mentioned by the comment above, you should always keep the optional variables on the right end, because php arguments evaluated from left to right. However, for this case you can do some trick to get rid of duplicate values as follows:
$var2 = 1, $var3 = 2, $var4 = 5;
function basicFunction($var1, $var2 = null, $var3 = null, $var4 = null) {
if($var2 === null)
$var2 = $GLOBALS["var2"];
if($var3 === null)
$var3 = $GLOBALS["var3"];
if($var4 === null)
$var4 = $GLOBALS["var4"];
}
However, you had better solve this situation by relocating you arguments cleverly.