function

Estimated reading time: 1 minute

function

function user() {
  echo("function name isn't case-sensitive");
}
user();
User();
# function name isn't case-sensitive

argument

function user($name,$status) {
  echo("${name} is a ${status}");
}
user("kamal","coder");
# kamal is a coder

default argument

function user($name,$status="artist") {
  echo("${name} is a ${status}");
}
user("kamal",);
# kamal is a artist

rest

function user(...$users) {
  echo $users[1];
}
user(5,7,6);
# 7
php