Jason Garber wrote:
  Here is a coding idea for you, in case you hadn't considered it...

  function highlight($text=NULL, $needle=NULL, $strip_links=NULL, ...)
  {
     is_null($text) && $text = SOME DEFAULT VALUE;
     is_null($needle) && $text = SOME DEFAULT VALUE;
     is_null($strip_links) && $text = SOME DEFAULT VALUE;
     ...
  }

We use

function highlight($p = array())
{
        $p += array(    # Also serves as documentation
                'text' => SOME_DEFAULT_VALUE,
                'needle' => SOME_DEFAULT_VALUE,
                'strip_links' => SOME_DEFAULT_VALUE,
                ...
        );
}
...
$highlight(array('strip_links' => true));

in cases just like this.

<shameless_plug>
Plus the patch from <http://cschneid.com/php> to get
$highlight('strip_links' => true);
</shameless_plug>

If named parameters for PHP are considered in the future then my main wish would be that there is a catch-all array receiving all the non-assignable parameters.

- Chris

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to