Introduction to PHP – 4

More about Functions

function with arguments.


define(“name” , “Gajjar”);
echo name;

function karan($k){
echo “<br>hi $k”;



NOTE: define(“name”,”Gajjar”) is same as a #define in C.

by default it is not case sensitive. Means in the second line if you echo NaME you will get error. To do so you need to define like this define(“name”,”Gajjar”,true); now you can echo as NAME ect.

One more imp : thing this define is called constant and these are global you can use it in function too!

function with Return type.


function multi($x,$y){

$z = $x*$y;
return $z;


echo “5 * 2 =”.multi(5,2).”<br>”;
echo “10 * 5 =”.multi(10,5).”<br>”;
echo “15 * 10 =”.multi(15,10).”<br>”;

function with Two arguments.


function name($first,$age=20){

echo “<br>$first is $age”;




These are so simple just remember syntax.Though if you have doubt feel free to ask!

Other inbuilt function in PHP you can find on internet.Btw we will try to cover in examples.!


Author: kanu_lp

Teck Geek guy... Bands Obsessed.

Leave a Reply

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

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

Google+ photo

You are commenting using your Google+ 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 )


Connecting to %s