#12712 [Com]: named function parameters

From: Date: Wed, 27 Aug 2008 08:37:52 +0000
Subject: #12712 [Com]: named function parameters
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-128468@lists.php.net to get a copy of this message
ID: 12712 Comment by: coder at muctr dot edu dot ru Reported By: martin at semester dot sk Status: Open Bug Type: Feature/Change Request Operating System: Windows 2000 PHP Version: 4.0.6 New Comment: Would like to add the reason. In medium to big projects (when many developers are involved) this feature could be of a great help. Because the code could be written in self-documenting manner. E.g. compare $html = formatSomeData( $data, true, false, true, 10 ); to $html = formatSomeData( entity_x: $data, italic: true, bold: false, monospace: true, fontSize: 10 ); In the second case one doesn't have to search for formatSomeData() definition to start using it. Previous Comments: ------------------------------------------------------------------------ [2002-04-28 19:45:37] jimw@php.net rewrote summary. ------------------------------------------------------------------------ [2001-08-13 04:05:59] martin at semester dot sk Good day. It is not a really bug report but a little suggestion for new PHP relase. I'll be good thing to add to PHP language ability to create functions with named parameters like in Visual Basic. For example: //Classic function: function printhello($name, $bold = false, $italic = false) { $ret = "Hello $name!" if ($bold) $ret = "<strong>$ret</strong>"; if ($italic) $ret = "<em>$ret</em>"; echo $ret; } //Suggested function: function printhello(name: $name, fat: $bold = false, emphased: $italic = false) { // same body as above ... } This new function could be called like: printhello("Martin", true); or like new: printhello(fat: true, name: "Martin"); Thank you. ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=12712&edit=1

« previous php.bugs (#128468) next »