knowledgediarybd.com

Your Virtual Knowledge Campus

PHP Function

php function,function in phpPHP Function is a powerful element in php programming.

PHP Function provides a lot of facilities.Due to the PHP function a big problem seems to very easy to understand.

About 700 built- in function are available in PHP.

Dear learner here you can learn php function,how to declare & how to call(call by reference & call by value) from any where of your page/php code.

Syntax of Simple PHP Function:

<html>

<head>

<title> www.knowledgediarybd.com</title>

<body>

<?php

function  function_name()

{

statement that have to executed;

}

call function here;

?>

</body>

</html>

An Example of simple php function:

<html>

<head>

<title> www.knowledgediarybd.com</title>

<body>

<?php

function  showmy_name()

{

echo”www.knowledgediarybd.com “;

}

echo”My Web site name is:”;
showmy_name();   /* here i call the above function*/

?>

</body>

</html>

Output of the above code :

My Web site name is:www.knowledgediarybd.com

Syntax of  PHP Function with argument/parameter:

we can use php function with argument/parameter which is also known as call by reference and call by value.
<?php

function function_Name (argument 1 ,argument 2..)
{
A statement that have to execute;

}

echo”My Web site name is:”;
showmy_name(argument 1);

echo”My  name is:”;
showmy_name(argument 1);
?>

An Example of  php function with argument/parameter:

<html>

<head>

<title> www.knowledgediarybd.com</title>

<body>

<?php

function showmy_name ($name)
{
echo $name . ” .com created by Humayun kabir<br>”;

}

echo”My Web site name is:”;
showmy_name(www.knowledgediarybd);

echo”My  another web site name is:”;
showmy_name(www.ccodegalaxy.blogspot);
?>

</body>

</html>

Output of the above code is:

My Web site name is:www.knowledgediarybd.com created by Humayun kabir
My anorher web site name is: www.ccodegalaxyblogspot.com created by Humayun kabir

Related Post:

knowledgediarybd.com © 2017
shares