Skip to main content

Posts

Showing posts with the label user defined function in php

PHP User Defined Functions

           PHP is packed full with many useful built-in functions, such as print() and mysql_query(), which meet a  variety of needs. However, there will be times when a non-standard function would best meet the needs of  the application that is being built.  This is where user defined functions come in handy.  The programmer  can of course write the same piece of code over and over again in their applications to produce the result or  they can create a user defined function that can be reused over and over again.  This is the primary  advantage of custom functions.  The actual code associated with built-in functions  consists of the keyword function followed by the  function name.  Next comes the parentheses, which may contain variable names, and the actual function  code itself, enclosed in curly braces:  function function_name () {      -- Statements that make up the function code  }  The following examples demonstrate some of the uses and capabilities for creating a user d