By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,987 Members | 997 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,987 IT Pros & Developers. It's quick & easy.

Functions and defaults

P: n/a
Consider a function header:

function init($name, $ttl, $need_bhid="N", $need_entity_id="N")

What values do the last two parameters have when it is called with the
following arguments:

init("name", "do name",,"Y");
Jun 19 '06 #1
Share this Question
Share on Google+
4 Replies


P: n/a
On Mon, 19 Jun 2006 17:50:52 -0400, Bob Stearns <rs**********@charter.net>
wrote:
Consider a function header:

function init($name, $ttl, $need_bhid="N", $need_entity_id="N")

What values do the last two parameters have when it is called with the
following arguments:

init("name", "do name",,"Y");


That's a syntax error.
--
Andy Hassall :: an**@andyh.co.uk :: http://www.andyh.co.uk
http://www.andyhsoftware.co.uk/space :: disk and FTP usage analysis tool
Jun 19 '06 #2

P: n/a
Andy Hassall wrote:
On Mon, 19 Jun 2006 17:50:52 -0400, Bob Stearns <rs**********@charter.net>
wrote:

Consider a function header:

function init($name, $ttl, $need_bhid="N", $need_entity_id="N")

What values do the last two parameters have when it is called with the
following arguments:

init("name", "do name",,"Y");

That's a syntax error.

That is too bad. It really should be "N" and "Y" with PHP honoring the
default values for all omitted arguments, not just trailing ones. Does
PHP v 5.x do it better?
Jun 19 '06 #3

P: n/a
On Mon, 19 Jun 2006 19:16:06 -0400, Bob Stearns <rs**********@charter.net>
wrote:
Andy Hassall wrote:
On Mon, 19 Jun 2006 17:50:52 -0400, Bob Stearns <rs**********@charter.net>
wrote:
Consider a function header:

function init($name, $ttl, $need_bhid="N", $need_entity_id="N")

What values do the last two parameters have when it is called with the
following arguments:

init("name", "do name",,"Y");


That's a syntax error.


That is too bad. It really should be "N" and "Y" with PHP honoring the
default values for all omitted arguments, not just trailing ones. Does
PHP v 5.x do it better?


No, C++-style skipping arguments in the middle of a list of arguments with
defaults is not supported in any current version of PHP.

(I don't know whether will be or not in PHP 6).
--
Andy Hassall :: an**@andyh.co.uk :: http://www.andyh.co.uk
http://www.andyhsoftware.co.uk/space :: disk and FTP usage analysis tool
Jun 19 '06 #4

P: n/a
Andy Hassall wrote:
On Mon, 19 Jun 2006 19:16:06 -0400, Bob Stearns <rs**********@charter.net>
wrote:

Andy Hassall wrote:
On Mon, 19 Jun 2006 17:50:52 -0400, Bob Stearns <rs**********@charter.net>
wrote:
Consider a function header:

function init($name, $ttl, $need_bhid="N", $need_entity_id="N")

What values do the last two parameters have when it is called with the
following arguments:

init("name", "do name",,"Y");

That's a syntax error.


That is too bad. It really should be "N" and "Y" with PHP honoring the
default values for all omitted arguments, not just trailing ones. Does
PHP v 5.x do it better?

No, C++-style skipping arguments in the middle of a list of arguments with
defaults is not supported in any current version of PHP.

(I don't know whether will be or not in PHP 6).

Put me down for a positive vote if one is being taken :-)
Jun 19 '06 #5

This discussion thread is closed

Replies have been disabled for this discussion.