PHP Classes
elePHPant
Icontem

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 (5 years ago) RSS 2.0 feedNot enough user ratingsTotal: 511 All time: 5,501 This week: 935Up
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 <contact>
Classes: 6 packages by
Country: Ghana Ghana
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:511
This week:0
All time:5,501
This week:935Up
User Comments (1)