Newsgroups: php.internals,php.internals Path: news.php.net Xref: news.php.net php.internals:32719 php.internals:32720 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 89002 invoked by uid 1010); 10 Oct 2007 09:54:23 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 88986 invoked from network); 10 Oct 2007 09:54:23 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 10 Oct 2007 09:54:23 -0000 X-Host-Fingerprint: 80.177.111.173 macvicar.demon.co.uk Received: from [80.177.111.173] ([80.177.111.173:11379] helo=localhost.localdomain) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id BE/A4-55062-D41AC074 for ; Wed, 10 Oct 2007 05:54:21 -0400 To: internals@lists.php.net, RQuadling@GoogleMail.com Message-ID: <470CA188.6060409@ntlworld.com> Date: Wed, 10 Oct 2007 10:55:20 +0100 User-Agent: Thunderbird 2.0.0.6 (Windows/20070728) MIME-Version: 1.0 CC: PHP Internals List References: <10845a340710100038p562cc239n29a412dc84650859@mail.gmail.com> In-Reply-To: <10845a340710100038p562cc239n29a412dc84650859@mail.gmail.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Posted-By: 80.177.111.173 Subject: Re: Q. zend_parse_parameters() - allow grouping of optional parameters. From: scottmacvicar@ntlworld.com (Scott MacVicar) if (ZEND_NUM_ARGS() != 3 && ZEND_NUM_ARGS() != 6 && ZEND_NUM_ARGS() != 7) { WRONG_PARAM_COUNT; } Will let you check that there are 3, 6 and 7 parameters. Scott Richard Quadling wrote: > Hi. > > From what I understand about the argument list for > zend_parse_parameters(), you separate optional parameters from > mandatory ones using pipe (|). > > e.g. > > if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "lll|llll", &m, > &d, &y, &h, &n, &s, &ms) == FAILURE) { > > In the above example, this says that there are 3 mandatory parameters > and upto 4 optional parameters. > > The prototype for this looks like ... > > proto bool myExampleDateFunc(int month, int day, int year, [int hour > [, int min [, int sec [,int msec]]]]) > > Is there a way to make the prototype ... > > proto bool myExampleDateFunc(int month, int day, int year, [int hour, > int min, int sec[, int msec]]) > > So, making this function accept 3 or 6 or 7 parameters only. > > I'm guessing not, but I'm guessing. I think this has to be checked using ... > > switch (ZEND_NUM_ARGS()) { > > after parsing the parameters and generate an error for ZEND_NUM_ARGS = 4 or 5. > > Regards, > > Richard. >