Hey all,
I am sort of new to PHP, but have been programming in Perl for a while. In most cases when passing args in perl, we used to do it in this style:
sub myfunction {
my $self = shift;
my $args = shift;
my $value1 = $args->{value1};
my $value2 = $args->{value2};
print "$value1, $value2";
}
$val1 = 'blah';
$val2 = '2';
$myvalue = $self->myfunction({value1=>$val1, value2=>$val2});
output: blah, 2
I am not so concerned about the "shifts" and $self, because php has the $this variable and such. What I am mainly asking is it possible to pass arguments like this in php?
If that isn't possible, can you decide not to pass arguments to a function?
I.E. in PHP
function myFunction($value1, $value2, $value3) {
$val1 = $value1 if $value1;
$val2 = $value2 if $value2;
$val3 = $value3 if $value3;
}
myFunction('blah',,);
I hope this question makes sense.
Thanks in advance!