In programming, a function is a section of code that can be invoked from other sections of the code or from other pages. The main benefit is that code that would otherwise be repeated often in a site can be placed in a function and invoked when needed. This makes for neater code and easier maintenance.