9 Things You Should Know Before Using Functions in PHP - Coding Cyber

9 Things You Should Know Before Using Functions in PHP

9 Things You Should Know Before Using Functions in PHP

Other Articles in PHP User Defined Functions Section

Quickly Navigate to Other Sections in PHP Tutorials

PHP Basics
PHP Data Types
PHP Advanced Data Types
PHP Logical Statements
PHP Operators
PHP Loops
User Defined Functions in PHP
Useful PHP Functions

PHP functions are used to execute some statements of code on a repetitive basis. PHP has some built-in functions, apart from that we can create our own functions. Function does not execute immediately after page load, we need to call the function to execute them.

PHP has more than 1000 built-in PHP functions.

PHP Function
Syntax for writing PHP Functions
For creating any function, we should first write function then after that function name with braces, after that in the curly braces code of statements to be executed after calling the function.

function functionName() {
code to be executed;
}

Syntax for calling PHP Functions
To execute the function, we need to call that function name with braces after it. Below is the sytax for calling function.
functionName();

Example code for writing PHP function & calling it
Here, I’m writing a simple function to display the message Hello world after calling the function.

function writeMsg() {
echo “Hello world!”;
}

writeMsg(); // call the function

Related Posts
No related posts for this content
Vivek Vengala
 

Vivek Vengala is a Online Entrepreneur, Web Developer from Hyderabad India.

Click Here to Leave a Comment Below 0 comments

Leave a Reply: