note 103458 added to functions.arguments

From: Date: Thu, 14 Apr 2011 13:15:44 +0000
Subject: note 103458 added to functions.arguments
Groups: php.notes 
Request: Send a blank email to php-notes+get-178825@lists.php.net to get a copy of this message
To someone who mentioned above regarding the following code: class A { public function __construct() { echo func_num_args() . "<br>"; var_dump( func_get_args()); echo "<br>"; } } This is actually not required and increasing your processing that you need to accomplish. Class constructors allow for variable numbers of inputs as follows (designer/programmer of the class decides as the class is being built): class A { public function __construct($arg1, $arg2, ..., $arg391) { // deal with arguments as required } } The only reason you would need to actually use the code you supplied above would be in cases where you have literally no idea what arguments the users might be passing your constructor, and in those cases your method would be the correct implementation. However, if you know what parameters you need to expect then use the second code example for better results. But, unlike my example I really don't recommend any one particular function having almost 400 different argument parameters (lol). ---- Server IP: 69.147.83.197 Probable Submitter: 174.5.38.168 ---- Manual Page -- http://www.php.net/manual/en/functions.arguments.php Edit -- https://master.php.net/note/edit/103458 Del: integrated -- https://master.php.net/note/delete/103458/integrated Del: useless -- https://master.php.net/note/delete/103458/useless Del: bad code -- https://master.php.net/note/delete/103458/bad+code Del: spam -- https://master.php.net/note/delete/103458/spam Del: non-english -- https://master.php.net/note/delete/103458/non-english Del: in docs -- https://master.php.net/note/delete/103458/in+docs Del: other reasons-- https://master.php.net/note/delete/103458 Reject -- https://master.php.net/note/reject/103458 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#178825) next »