I am not sure what the correct name is for this feature, but it does make function calling more convenient. Take this for an example:
<?php
function hold_the_line($soldier='Major Rawne',
$regiment_leader='Colonel-Commissar Gaunt',
$planet='Tanith') {
print "Soldier: ".$soldier;
print "Regiment Leader: ".$regiment_leader;
print " from ".$planet;
}
hold_the_line($planet='Vervunhive');
?>
This is what I am talking about. PHP will completely ignore, deliberately or other, the $planet, thus outputting,
Soldier: Vervunhive, Regiment Leader: Colonel-Commissar Gaunt from Tanith
This makes default arguments all the more difficult. If you do this in Python,
def hold_the_line(soldier='Major Rawne', regiment_leader='Colonel-Commissar Gaunt', planet='Tanith'): print "Soldier: " + soldier print "Regiment Leader: " + regiment_leader print " from " + planet hold_the_line(planet='Vervunhive')
you would get this,
Soldier: Major Rawne Regiment Leader: Colonel-Commissar Gaunt from Vervunhive
Cool, eh? PHP needs this. Not sure if it’ll appear in PHP6.

No comments yet
Comments feed for this article