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    
Ratings Unique User Downloads Download Rankings
StarStarStar 43%Total: 515 This week: 1All time: 5,735 This week: 560Up
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
Picture of Stefan Jibrail Froelich
  Performance   Level  
Name: Stefan Jibrail Froelich is available for providing paid consulting. Contact Stefan Jibrail Froelich .
Classes: 6 packages by
Country: United States United States
Age: ???
All time rank: 1106159 in United States United States
Week rank: 411 Up48 in United States United States Up
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  
 0%
Total:515
This week:1
All time:5,735
This week:560Up
User Ratings User Comments (1)
 All time
Utility:62%StarStarStarStar
Consistency:62%StarStarStarStar
Documentation:-
Examples:62%StarStarStarStar
Tests:-
Videos:-
Overall:43%StarStarStar
Rank:3486