Bab 10
Fungsi/Function
Fungsi merupakan sebuah blok program yang dapat dieksekusi kapanpun kita memerlukannya.
Program10-1.php
Program10-2.php:
";
echo "My name is ";
writeMyName();
echo ".
That's right, ";
writeMyName();
echo " is my name.";
?>
Ouput program:
Hello world!
My name is Kai Jim Refsnes.
That's right, Kai Jim Refsnes is my name.
Fungsi berparameter
Program10-3.php
";
}
echo "My name is ";
writeMyName("Kai Jim");
echo "My name is ";
writeMyName("Hege");
echo "My name is ";
writeMyName("Stale");
?>
output program:
My name is Kai Jim Refsnes.
My name is Hege Refsnes.
My name is Stale Refsnes.
Program10-4.php
";
}
echo "My name is ";
writeMyName("Kai Jim",".");
echo "My name is ";
writeMyName("Hege","!");
echo "My name is ";
writeMyName("Ståle","...");
?>
output:
My name is Kai Jim Refsnes.
My name is Hege Refsnes!
My name is Ståle Refsnes...
Fungsi yang mengembalikan sebuah nilai
Program10-5.php
output :
1 + 16 = 17
Minggu, 04 Mei 2014
Langganan:
Posting Komentar (Atom)
0 komentar:
Posting Komentar