How to alias a function in PHP?

Until PHP 5.5

yup, function wait ($seconds) { sleep($seconds); } is the way to go. But if you are worried about having to change wait() should you change the number of parameters for sleep() then you might want to do the following instead:

function wait() { 
  return call_user_func_array("sleep", func_get_args());
}

Leave a Comment