not sure all the bits you where trying to do.. but function calls::::

function test () {
    print_r(func_get_args());
}
test("a","w","C');

more normally...

function test($a,$b=NULL) {
       if ($b===NULL) { // tripple equal to make sure that "" != NULL
            $b=$a
            $a = "id";
       }
        ......
}

test(12);
test("name","fred");

regards
Alan


Pascal Van Hecke wrote:

>Hi,
>
>I was using Torben Nehmer's Wrapper class CArticle
>(http://www.nathan-syntronics.de/midgard/oop/baseclasses/CArticle.html,
>read
>http://www.nathan-syntronics.de/midgard/oop/extending.html
>for backgroundinfo).
>In my own implementation (I actually extend CArticle,
>but that's not relevant here) I wanted to have a
>constructor that would be the equivalent of
>mgd_get_article_by_name($topic_id, $article_name).  In
>Torben's CArticle, only the behaviour of
>mgd_get_article($article_id) is mimicked by 
>
>new CArticle($article_id);
>
>Now, in another language than PHP, there would be no
>problem creating a second constructor with a different
>signature, thus:
>
>$article = new CArticle($article_id);
>$article = new CArticle($topic_id, $article_name);
>
>making two different constructors.  This is not
>possible in php however (well, strictly spoken it is
>possible with Variable-length argument lists, see
>further).  The way I solved it now is:
>
>$article_pointer = new CArticle(); // instantiating a
>still empty object with ID 0  
>$article_pointer->assign_to_article_by_name($this->topic_id,
>$this->article_id);
>
>with the implementation of 
>"assign_to_article_by_name" reading: 
>
>function assign_to_article_by_name($par_topic_id,
>$par_article_id)
>{    
>  $article = mgd_get_article_by_name ($par_topic_id,
>$par_article_id);
>  if (!$article) 
>  {
>    $this = false;
>    return false;
>  }
>  $this->_copyMgdData($article);
>}
>
>This is a bit ugly, because if I call
>assign_to_article_by_name on an already filled
>CArticle object, its own content is overwritten by the
>found article in the indicated topic and with the
>indicated name in mgd_get_article_by_name .
>
>Alternatives here:
>PHP does allow for a varying number of parameters, but
>it's a bit ugly again.  In the constructor, you could
>test on the number of parameters but this would still
>allow only one implementation with 1 parameter, only
>one implementation with 2 parameters, etc...
>
>Maybe an extra parameter would be better:
>function CArticle ($par_constructortype = "id",
>$par_parameter_array)
>{
>  if ($par_constructortype="id")
>  {
>  ...
>  }
>  if ($par_constructortype="name")
>  {
>  ...
>  }
>}
>A possible problem with the last implementation is
>that overriding the constructor in an inherited class
>becomes a bit more complex?
>
>Torben, Philipp and other users of the extended
>MidgardClasses, maybe you could give your opinion
>here?
>
>pascal
>
>__________________________________________________
>Do You Yahoo!?
>Yahoo! Finance - Get real-time stock quotes
>http://finance.yahoo.com
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: [EMAIL PROTECTED]
>For additional commands, e-mail: [EMAIL PROTECTED]
>
>  
>




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to