Functions in PHP
Subject: Web development using PHP and MySQL
In programming, when we are discussing functions we are either referring to the built-in function that comes with the language or the User defined or custom function that the programer would like to create..
Built-in functions
PHP has lots of built-in functions some of which we have seen, for example the echo or print, date, array, mail, math, msqli, strings etc.
Date function
display the current time and date
pi() math function
Custom or user-defined function
Custom or user-defined function as the name suggest, are function you create to solve a particular problem or execute a task that occurs severally, this save you from the time or effort required to rewrite such code and also makes your program easy to understand and maintain.
So you create such function once and call it whenever you need.
Example 1
Example 2.
Function with arguments, takes in values and return a result.
Output
900
By:
Benjamin Onuorah
Comments
Abah Johnson (learner)
Date commented: 16-May-2024 04:47:02am
Login to comment or ask question on this topic
Previous Topic Next Topic