Learn PHP Functions with examples.
Learn PHP Functions with examples.In this section we will understand important PHP functions with the help of example code.
What is Functions?
Function is a block of code to do some processing. The function contains the logic to do an unit of work. For example you can create function to check if an user is valid or not by passing username and password as parameter. In the function declaration you may have to write code to connect to database and validate user.
Here is an example of custom function:
function validateUser($username,$password) { $isValidUser=false; //Write code to connect to database and then validate user //if user found set the value of variable $isValidUser to true //finally return the $isValidUser value return $isValidUser; }
Functions in PHP
PHP provides many built-in functions to do the real job. There are around 5000 functions available in PHP. These functions provides a lot functionalities. It helps the developers to do complex programming easily and rapidly.
Here are the list of important PHP functions with explanation and example code:
PHP date_create_from_format function