PHP Function

Very most time we need to use or display same name or same result in every step. At that time PHP function is very much useful to do that.First time,we have to apply function and to call the result we use return option.If called from within a function, the return statement immediately ends execution of the current function, and returns its argument as the value of the function call. return will also end the execution of an eval() statement or script file.

At the beginning of the function, you need to give it a name, like creativemssion. It's with this function name that you will be able to call in your function, now write the code it easy to write and understand.

In this chapter we will present you how to create your own functions.

Here is how to make a function called creativemission. Note: We still have to fill in the code for creativemission.

PHP code

<?php function creativemission(){ } ?>

Note: Your function name can start with a letter or underscore "_", but not a number!

To active the code when the page will loading, you can put it into a function.

A function will be executed when the code will call to the function.

You may call a function from anywhere within a page.


function function_name(argument) { code to be executed; return variable; } print f(); ?>



function adding($x1,$x2)

{ $result=$x1+$x2; return $result; }

print adding(2,3);


All Tutorial => 12345678910

Write Comment