Ratings | | Unique User Downloads | | Download Rankings |
Not yet rated by the users | | Total: 85 | | All time: 10,034 This week: 206 |
|
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
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 |
| |
|
|
Innovation award
Nominee: 8x
Winner: 2x |
|
Example
<?php
$adam = "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();
foreach($a[0] as $person){
echo $person."<br>";
}
|
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>
|
Applications that use this package |
|
No pages of applications that use this class were specified.
If you know an application of this package, send a message to the author to add a link here.