[prev] [index] [next]

Functions (cont)

Notes on function definitions:
  • don't specify argument types or return type
  • can specify default values for arguments
    • can omit arguments from right-to-left if default values given
    • if no defaults are given, missing arguments generate errors
  • can handle variable-length argument lists (like C's printf)
    • using special functions func_num_args(), func_get_arg(), and func_get_args()