Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:32731 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 10471 invoked by uid 1010); 10 Oct 2007 18:17:43 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 10456 invoked from network); 10 Oct 2007 18:17:43 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 10 Oct 2007 18:17:43 -0000 Authentication-Results: pb1.pair.com header.from=andrei@gravitonic.com; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=andrei@gravitonic.com; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain gravitonic.com from 204.11.219.139 cause and error) X-PHP-List-Original-Sender: andrei@gravitonic.com X-Host-Fingerprint: 204.11.219.139 mail.lerdorf.com Received: from [204.11.219.139] ([204.11.219.139:57167] helo=mail.lerdorf.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 72/28-55062-5471D074 for ; Wed, 10 Oct 2007 14:17:42 -0400 Received: from [64.0.236.50] (da001d1074.cam-ma.osd.concentric.net [64.0.236.50]) (authenticated bits=0) by mail.lerdorf.com (8.14.1/8.14.1/Debian-10) with ESMTP id l9AIHZJU027690; Wed, 10 Oct 2007 11:17:35 -0700 In-Reply-To: <470CA188.6060409@ntlworld.com> References: <10845a340710100038p562cc239n29a412dc84650859@mail.gmail.com> <470CA188.6060409@ntlworld.com> Mime-Version: 1.0 (Apple Message framework v752.2) Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed Message-ID: Cc: RQuadling@GoogleMail.com, PHP Internals List Content-Transfer-Encoding: 7bit Date: Wed, 10 Oct 2007 11:17:35 -0700 To: Scott MacVicar X-Mailer: Apple Mail (2.752.2) X-Virus-Scanned: ClamAV 0.91.2/4521/Wed Oct 10 00:58:01 2007 on colo.lerdorf.com X-Virus-Status: Clean Subject: Re: [PHP-DEV] Re: Q. zend_parse_parameters() - allow grouping of optional parameters. From: andrei@gravitonic.com (Andrei Zmievski) Use quite parameter parsing: if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS() TSRMLS_CC, "lll", &m, &d, &y) != SUCCESS && zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS() TSRMLS_CC, "llllll", &m, &d, &y, &h, &min, &s) != SUCCESS && zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS() TSRMLS_CC, "llllll", &m, &d, &y, &h, &min, &s, &ms) != SUCCESS) { php_error(E_WARNING, "Could not parse parameters"); } Disadvantage is that you will not get the nicely formatted error message and have to do it yourself. -Andrei http://10fathoms.org/vu - daily photoblog On Oct 10, 2007, at 2:55 AM, Scott MacVicar wrote: > 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. >> > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php