note 60198 added to functions.arguments

From: Date: Thu, 29 Dec 2005 16:59:56 +0000
Subject: note 60198 added to functions.arguments
Groups: php.notes 
Request: Send a blank email to php-notes+get-100940@lists.php.net to get a copy of this message
For those looking at this page for a way to use named arguments, here's an alternative. <?php class named { } $named = new named(); function foo() { global $named; if (isset($named->var)) { echo "\$var passed as an argument"; } } echo foo(); echo foo($named->var = "test"); /* Outputs: foo() called foo() called $var passed as an argument */ ?> I think it produces more readable code than using arrays or eval(). *Shameless plug*: I wrote a post about how you can use this approach more extensively (with examples too) here: http://tinyurl.com/apts7 ---- Manual Page -- http://www.php.net/manual/en/functions.arguments.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+60198 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+60198&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+60198&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+60198&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+60198&report=yes&reason=useless Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+60198&report=yes&reason=non-english Delete: already in docs -- http://master.php.net/manage/user-notes.php?action=delete+60198&report=yes&reason=already+in+docs Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+60198&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+60198&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#100940) next »