instead of using the standard method of passing mixed data to
functions, where you have to track back to the function to see what
the data structure is...
$result = myFunction( array( $id, array('nolog', 'blank'), $data);
Instead pass an array with the elements labeled:
$result = myFunction( array(
'id' => $id
,'options'=> array('nolog', 'blank')
,'data' => $data
));
Any opinions?
I guess it depends on what you need. I don't see anything wrong with
it, but am struggling to come up with a real-world reason to use it over
a standard parameter list (with default values, if necessary). But then
I don't often pass mixed data to functions. I find it has a tendency to
overly-complicate the code, and I always code for clarity first.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstu...@attglobal.net
==================
Yes there's lots out there. And several languages which use named
parameters. Have google.
C.
$result = myFunction((object)array(
'id' => $id,
'options'=> array('nolog', 'blank'),
'data' => $data
));
$test = (object)array(
'id' => 'hi',
'options'=> array('nolog', 'blank'),
'data' => 'stuff'
);
echo $test->hi;