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)    
Last Updated Ratings Unique User Downloads Download Rankings
2020-12-30 (11 months ago) RSS 2.0 feedNot yet rated by the usersTotal: 79 All time: 9,777 This week: 243Up
Version License PHP version Categories
speciala-rguments 1.0The PHP License5PHP 5, Language
Description Author

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: 18 packages by
Country: Poland Poland
Age: ???
All time rank: 81523 in Poland Poland
Week rank: 43 Up1 in Poland Poland Up
Innovation award
Innovation award
Nominee: 5x

Winner: 2x

Details

speciala-rguments

     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 <ber34@o2.pl>

     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  <ber34@o2.pl>
  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 README.md Doc. Documentation

 Version Control Unique User Downloads Download Rankings  
 100%
Total:79
This week:0
All time:9,777
This week:243Up
For more information send a message to info at phpclasses dot org.