Thursday, 19 September 2013

PHP function varying parameters

PHP function varying parameters

I couldn't find about my issue on google and SO. Hope, i can explain you.
You'll understand when looked following function:
function get_page($identity)
{
if($identity is id)
$page = $this->get_page_from_model_by_id($identity);
elseif($identity is alias)
$page = $this->get_page_from_model_by_alias($identity);
}
My used function:
get_page(5); // with id
or
get_page('about-us'); // with alias
or
get_page(5, 'about-us'); // with both
I want to send parameter to function id or alias. It should be only one
identifier.
I dont want like function get_page($id, $alias)
How can i get and know parameter type with only one variable. Is there any
function or it possible?

No comments:

Post a Comment