pivopen May 1, 2025 0 4
pivopen May 1, 2025 0 6
pivopen Apr 26, 2025 0 9
pivopen May 2, 2025 0 1
pivopen May 2, 2025 0 3
pivopen May 2, 2025 0 2
Join our subscribers list to get the latest news, updates and special offers directly in your inbox
PHP Tutorials
In PHP, if statements are used to execute code based on conditions. Here's the basic syntax:
if
if (condition) { // code to execute if condition is true }
1. Simple if statement:
$age = 20; if ($age >= 18) { echo "You are an adult."; }
2. if-else statement:
$age = 16; if ($age >= 18) { echo "You are an adult."; } else { echo "You are a minor."; }
3. if-elseif-else statement:
$score = 85; if ($score >= 90) { echo "Grade: A"; } elseif ($score >= 80) { echo "Grade: B"; } elseif ($score >= 70) { echo "Grade: C"; } else { echo "Grade: F"; }
4. Nested if statements:
$age = 25; $hasID = true; if ($age >= 18) { if ($hasID) { echo "You may enter."; } else { echo "You need an ID."; } }
Previous Article
Next Article
Like
Dislike
Love
Funny
Angry
Sad
Wow
pivopen
pivopen May 1, 2025 0 7
pivopen May 1, 2025 0 5