Belajar Coding PHP Pemula Secara Interaktif & Fun Master PHP Coding Step by Step from Scratch
Latihan koding PHP pemula dari nol. Pelajari syntax dasar, manipulasi array, fungsi, OOP, hingga SOLID principles pake instant test runner di browser. Gratis & tanpa install! Practice syntax, arrays, OOP, and SOLID principles with an interactive sandbox test engine right in your browser. Free & no installation required.
01. Formatting Greeting & Concatenation 01. Formatting Greeting & Concatenation
Buat fungsi `formatGreeting($name)` yang menerima parameter string nama dan mengembalikan string ucapan `"Halo, {name}! Selamat belajar PHP."`. Create a function `formatGreeting($name)` that takes a string name parameter and returns `"Halo, {name}! Selamat belajar PHP."`.
02. Sum of Even Numbers in Array 02. Sum of Even Numbers in Array
Buat fungsi `sumEvenNumbers($numbers)` yang menerima array berisi angka integer dan mengembalikan jumlah (sum) dari seluruh angka genap dalam array tersebut. Create a function `sumEvenNumbers($numbers)` that accepts an array of integers and returns the sum of all even numbers.
03. Clean Code URL Slug Generator 03. Clean Code URL Slug Generator
Buat fungsi `generateSlug($title)` yang mengubah judul artikel menjadi format URL slug (lowercase, spasi diganti strip `-`, hapus karakter khusus selain huruf & angka). Create a function `generateSlug($title)` that converts a title into a clean URL slug (lowercased, spaces replaced by `-`, non-alphanumeric characters stripped).
04. SOLID Principles: Order Discount Calculator 04. SOLID Principles: Order Discount Calculator
Buat fungsi `calculateFinalPrice($subtotal, $membership)` dengan aturan: Jika membership `"PREMIUM"` berikan diskon 20%, jika `"MEMBER"` berikan diskon 10%, jika `"GUEST"` diskon 0%. Jika total setelah diskon >= 500000, berikan potongan tambahan flat Rp 25.000. Create a function `calculateFinalPrice($subtotal, $membership)` with rules: PREMIUM gets 20% discount, MEMBER gets 10%, GUEST gets 0%. If total after percentage discount is >= 500,000, apply an extra flat 25,000 discount.
05. Palindrome Phrase Inspector 05. Palindrome Phrase Inspector
Buat fungsi `isPalindrome($text)` yang mengembalikan `true` jika kata/kalimat adalah palindrom (dibaca sama dari depan & belakang, abaikan spasi & kapitalisasi), dan `false` jika bukan. Create a function `isPalindrome($text)` that returns `true` if a phrase is a palindrome (ignoring spaces, punctuation & case), and `false` otherwise.