PHP Functions
Now that we know the basic loop statements that are commonly used in PHP, we come to one of PHP’s real power in the form of it’s built in functions. PHP has over 700 built-in functions which gives the programmer a lot of quick and fun ways to do things they would otherwise have to create code for. Functions are simply blocks of code that are pre-made and called upon when needed to perform their task returning control to the calling statement after execution. In PHP, one creates functions by using the “function()” statement, which is then assigned a name that is simple yet descriptive of the process the function is to do (though this is not necessary, it would be nice to have a function that is easily determined through its descriptive name), that way when you debug programs you can have a general idea what that particular function is supposed to do. a function can start with an underscore or a letter but never a number. As the program starts, the “{” signals the start of the function after the opened curly braces, the function code or block of code is then inserted then followed by the closing curly brace, “}” to close the function.
A sample of a function will be given on the next post.
Filed under: Basic Programming by Avatar
