Skip to content

Instantly share code, notes, and snippets.

@compwright
Created September 2, 2013 18:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save compwright/6415942 to your computer and use it in GitHub Desktop.
Save compwright/6415942 to your computer and use it in GitHub Desktop.
Illustrating how to optionally support named argument arrays in PHP methods
<?php
function getFriends(
$user_id = null,
$screen_name = null,
$cursor = -1,
$skip_status = false,
$include_user_entities = false
) {
// Support optionally named parameters via an array
if (func_num_args() === 1 && is_array(func_get_arg(0)))
{
extract(func_get_arg(0));
}
// do stuff...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment