PHP Classes

PHP Class Constructor with Parameters: How to access all the class constructor parameters

Recommend this page to a friend!
  Info   View files Example   View files View files (4)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog (1)    
Ratings Unique User Downloads Download Rankings
Not yet rated by the usersTotal: 85 All time: 10,012 This week: 206Up
Version License PHP version Categories
speciala-rguments 1.0The PHP License5PHP 5, Language


This class can show how to access all the class constructor parameters.

It is an example class with a constructor function that takes all its parameter values and store them in an array class variable.

Another class function can return the array with all the parameter values that were previously passed to the class constructor function.

Innovation Award
PHP Programming Innovation award nominee
December 2020
Number 3
PHP classes can have constructor functions that are called once a class object is created.

Like other types of functions, constructor functions can have a variable number of parameters.

This class demonstrates how to handle class constructor function calls by storing all the parameters in a way that they can be accessed later, regardless of the number of the parameters that were passed.

Manuel Lemos
Picture of adam berger
  Performance   Level  
Name: adam berger <contact>
Classes: 23 packages by
Country: Poland Poland
Age: ???
All time rank: 74621 in Poland Poland
Week rank: 289 Up7 in Poland Poland Up
Innovation award
Innovation award
Nominee: 8x

Winner: 2x



= "1 person";
$ginter = "2 person";
$bodzio = "3 person";
$endriu = "4 person";
$bandzo = "5 person";
$test = new special_arguments($adam, $ginter, $bodzio, $endriu, $bandzo);
$a = $test->car();
$a[0] as $person){



     Je?eli nie wiemy ile parametrów b?dziemy przekazywa? do konstruktora
     mo?emy zrobi? to w ten sposób.
     Nie musimy ingerowa? w sam? klas? za ka?dym razem kiedy dopisujemy
     kolejny parametr.
     Za?ó?my ?e mamy samochód w którym nie wiemy ile osób b?dzie podró?owa?,
     a chcemy przekaza? do konstruktora, za ka?dym razem inn? ilo?? osób.
     Czy mo?emy o zawartych w klasie regu?ach powiedzie?, ?e jest nowym wzorcem
     projektowym Special Arguments.
     Prze?lijcie wasze opinie na email <>

     If you do not know how many parameters we pass to the constructor, 
     we can do it this way.
We do not need to interfere in the same class each time when 
we add another parameter.
Suppose that we have a car that does not know how many people will travel
and we want to pass to the constructor, each time a different number of people.
Are we about contained in the class rules say that it is a new design
pattern Special Arguments.
Please send your feedback by email  <>

  Files folder image Files  
File Role Description
Plain text file class_special_arguments.php Class Class source
Accessible without login Plain text file index.php Example Example script
Accessible without login Plain text file LICENSE Lic. License text
Accessible without login Plain text file Doc. Documentation

 Version Control Unique User Downloads Download Rankings  
This week:0
All time:10,012
This week:206Up