Presentation is loading. Please wait.

Presentation is loading. Please wait.

Bayu Priyambadha, S.Kom.  Block of script that is defined with certain name for specific job  Function is defined one time, and called many time  Function.

Similar presentations


Presentation on theme: "Bayu Priyambadha, S.Kom.  Block of script that is defined with certain name for specific job  Function is defined one time, and called many time  Function."— Presentation transcript:

1 Bayu Priyambadha, S.Kom

2  Block of script that is defined with certain name for specific job  Function is defined one time, and called many time  Function is defined for maintainability purpose

3  Without return value (void function) function header() { echo “ ”; echo “ Test Function ”; echo “ ”; }  With return value function gabungString($kiri, $kanan) { return $kiri.$kanan; }

4  In Pascal, without return value function is called Procedure  In C/C++, without return value function is called Void Function  In Java, without return value function is called Void Method

5  How to define function? ◦ No Return Value function nameoffunction(parameters) { statement; } ◦ Return Value function nameoffunction(parameters) { statement; return; }

6  Pass by Value function kalidua($nilai) { $nilai = $nilai * 2; return $nilai; }  Pass by Reference function kalidua(&$nilai) { $nilai = $nilai * 2; return $nilai; }

7  Default paramater, give default value to parameter function kalidua($nilai = 1) { $nilai = $nilai * 2; return $nilai; }

8  Single Return Value function return_one() { return 30; }  Multiple Return Value function return_multiple() { return array(30,40); }

9

10

11

12


Download ppt "Bayu Priyambadha, S.Kom.  Block of script that is defined with certain name for specific job  Function is defined one time, and called many time  Function."

Similar presentations


Ads by Google