Login   Register  
PHP Classes
elePHPant
Icontem

Named Parameters: Call functions passing parameters by name

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  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 (3 years ago) RSS 2.0 feedNot enough user ratingsTotal: 500 All time: 5,257 This week: 1,452Up
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
Name: Stefan Jibrail Froelich is available for providing paid consulting. Contact Stefan Jibrail Froelich .
Classes: 4 packages by
Country: Ghana Ghana
Age: ???
All time rank: 11442 in Ghana Ghana
Week rank: 713 Up2 in Ghana Ghana Equal
Innovation award
Innovation award
Nominee: 2x

  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:500All time:5,257
 This week:0This week:1,452Up
 User Comments (1)