note 61597 added to functions.arguments

From: Date: Tue, 07 Feb 2006 15:55:07 +0000
Subject: note 61597 added to functions.arguments
Groups: php.notes 
Request: Send a blank email to php-notes+get-103204@lists.php.net to get a copy of this message
by default Classes constructor does not have any arguments. Using small trick with func_get_args() and other relative functions constructor becomes a function w/ args (tested in php 5.1.2). Check it out: class A { public function __construct() { echo func_num_args() . "<br>"; var_dump( func_get_args()); echo "<br>"; } } $oA = new A(); $oA = new A( 1, 2, 3, "txt"); Output: 0 array(0) { } 4 array(4) { [0]=> int(1) [1]=> int(2) [2]=> int(3) [3]=> string(3) "txt" } ---- Server IP: 64.246.30.37 Probable Submitter: 131.225.163.89 ---- Manual Page -- http://www.php.net/manual/en/functions.arguments.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+61597 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+61597&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+61597&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+61597&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+61597&report=yes&reason=useless Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+61597&report=yes&reason=non-english Delete: already in docs -- http://master.php.net/manage/user-notes.php?action=delete+61597&report=yes&reason=already+in+docs Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+61597&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+61597&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#103204) next »