PHP Classes

Named Parameters: Call functions passing parameters by name

Recommend this page to a friend!
  Info   View files View files (2)   DownloadInstall with Composer Download .zip   Reputation   Support forum (2)   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2011-08-24 (8 years ago) RSS 2.0 feedStarStarStar 46%Total: 513 All time: 5,642 This week: 307Up
Version License PHP version Categories
named-params 1Artistic License5PHP 5, Language
Description Author

This class allows callin functions by passing parameters by name.

It can call a given global function or object function by passing parameters to it by their names instead of having to use the declaration parameter order.

The class uses reflection to determine the function parameter names and parses a string with parameters to extract the parameters values to be passed. It assumes default values for missing parameters.

Innovation Award
PHP Programming Innovation award nominee
September 2011
Number 9
Currently PHP requires that you pass parameters to functions by the order they are defined.

Often you do not remember the order of those parameters and you need to check the PHP manual to see what is the right order of each parameter.

An alternative solution would be to support named parameters, so the PHP developers could specify the parameters by any order, just by specifying their names.

Currently PHP does not support named parameters but this class provides a solution that emulates that feature using text strings to pass the parameters to a function.

Manuel Lemos
  Performance   Level  
Name: Stefan Jibrail Froelich is available for providing paid consulting. Contact Stefan Jibrail Froelich .
Classes: 6 packages by
Country: Ghana Ghana
Age: ???
All time rank: 11072 in Ghana Ghana
Week rank: 672 Up3 in Ghana Ghana Down
Innovation award
Innovation award
Nominee: 3x


  Files folder image Files  
File Role Description
Plain text file namedparams.class.php Class the main class
Accessible without login Plain text file namedparams.examples.php Example examples and tutorial

 Version Control Unique User Downloads Download Rankings  
This week:0
All time:5,642
This week:307Up
User Ratings User Comments (1)
 All time