9. Function and Return

What is function: PHP functions are similar to other programming languages. A function is a piece of code which takes one more input in the form of parameter and does some processing and returns a value. Function will be executed by a call to the function. The real power of PHP comes from its functions. it has more than 1000 built-in functions. Besides the built-in PHP functions, we can create our own functions.

A user defined function declaration starts with the word “function”.

<?php
	function writeMsg() {
		echo "Hello world!";
	}
	writeMsg(); // call the function
?>

Return: anything’s Return from function then other codes not run or execute.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s