Created
August 3, 2018 23:10
Star
You must be signed in to star a gist
sample code of function in php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function ucapSalam() { | |
echo "Assalamualaikum"; | |
} | |
//cara panggil function | |
ucapSalam(); | |
function namaKeluarga($namaAwal) { | |
echo "$namaAwal Udin.<br>"; | |
} | |
namaKeluarga("Jamal"); | |
namaKeluarga("Sarif"); | |
namaKeluarga("Nur"); | |
namaKeluarga("Arief"); | |
namaKeluarga("Rohman"); | |
function biodata($nama, $tahun) { | |
echo "Si $nama . Lahir pada tahun $tahun <br>"; | |
} | |
biodata("Andi", "1997"); | |
biodata("Kusuma", "2008"); | |
biodata("Novanto", "1887"); | |
function setTinggi($minTinggi = 150) { | |
echo "Tinggi nya Dia adalah : $minTinggi <br>"; | |
} | |
setTinggi(350); | |
setTinggi(); // Akan menggunakan nilah default | |
setTinggi(135); | |
setTinggi(80); | |
function tambah($x, $y) { | |
$z = $x + $y; | |
return $z; | |
} | |
echo "6 + 12 = " . tambah(6, 12) . "<br>"; | |
echo "9 + 13 = " . tambah(9, 13) . "<br>"; | |
echo "2 + 44 = " . tambah(2, 44); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment