{"id":69,"date":"2026-05-20T07:44:28","date_gmt":"2026-05-20T07:44:28","guid":{"rendered":"https:\/\/gigz.pk\/php\/?post_type=lesson&#038;p=69"},"modified":"2026-05-21T14:37:55","modified_gmt":"2026-05-21T14:37:55","slug":"if-else-if-else","status":"publish","type":"lesson","link":"https:\/\/gigz.pk\/php\/?lesson=if-else-if-else","title":{"rendered":"if, else if, else"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">Introduction<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The if else if else statement in web development is used to make decisions in a program based on different conditions. It allows a website or application to respond differently depending on user input, data values, or system states. This concept is widely used in PHP, JavaScript, and other programming languages used in website development.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">What is If Else If Else<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The if else if else structure is a conditional control statement that checks multiple conditions in sequence. If the first condition is true, its block of code runs. If it is false, the program moves to the next condition using else if. If none of the conditions are true, the else block runs as a default action.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Why It Is Important in Web Development<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">It helps developers create dynamic and interactive websites. It is used for login systems, form validation, user roles, pricing rules, and content display based on conditions.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Basic Logic Flow<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">First condition is checked<br>If true then execute code block<br>If false then move to next condition<br>Check else if condition<br>If still false then execute else block<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Example in PHP<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;?php<br>$marks = 75;<br><br>if ($marks &gt;= 80) {<br>    echo \"Grade A\";<br>}<br>else if ($marks &gt;= 60) {<br>    echo \"Grade B\";<br>}<br>else if ($marks &gt;= 40) {<br>    echo \"Grade C\";<br>}<br>else {<br>    echo \"Fail\";<br>}<br>?&gt;<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Example in JavaScript<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>let age = 18;<br><br>if (age &gt;= 18) {<br>    console.log(\"Adult\");<br>}<br>else if (age &gt;= 13) {<br>    console.log(\"Teenager\");<br>}<br>else {<br>    console.log(\"Child\");<br>}<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Real World Uses in Websites<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Login authentication systems<br>User role management like admin or user<br>Discount calculation in e commerce websites<br>Form validation messages<br>Content display based on user location<br>Access control for premium content<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Best Practices<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Keep conditions simple and readable<br>Always use proper indentation<br>Place most important condition first<br>Use meaningful variable names<br>Avoid too many nested conditions<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Advantages<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Helps in decision making in code<br>Improves website interactivity<br>Makes applications dynamic<br>Easy to implement and understand<br>Works in all major programming languages<\/p>\n\n\n<div class=\"yoast-breadcrumbs\"><span><span><a href=\"https:\/\/gigz.pk\/php\">Home<\/a><\/span> \u00bb <span class=\"breadcrumb_last\" aria-current=\"page\">PHP Fundamentals (Beginner Level) > Operators and Conditions > if, else if, else<\/span><\/span><\/div>\n\n\n<div class=\"schema-faq wp-block-yoast-faq-block\"><div class=\"schema-faq-section\" id=\"faq-question-1779263037922\"><strong class=\"schema-faq-question\"><\/strong> <p class=\"schema-faq-answer\"><\/p> <\/div> <\/div>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n","protected":false},"menu_order":14,"template":"","class_list":["post-69","lesson","type-lesson","status-publish","hentry"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.8 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>if, else if, else - Learn PHP with GiGz.PK<\/title>\n<meta name=\"description\" content=\"Learn if else if else statements in web development with PHP and JavaScript examples, logic flow, and real world website usage guide\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/gigz.pk\/php\/?lesson=if-else-if-else\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"if, else if, else - Learn PHP with GiGz.PK\" \/>\n<meta property=\"og:description\" content=\"Learn if else if else statements in web development with PHP and JavaScript examples, logic flow, and real world website usage guide\" \/>\n<meta property=\"og:url\" content=\"https:\/\/gigz.pk\/php\/?lesson=if-else-if-else\" \/>\n<meta property=\"og:site_name\" content=\"Learn PHP with GiGz.PK\" \/>\n<meta property=\"article:modified_time\" content=\"2026-05-21T14:37:55+00:00\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":[\"WebPage\",\"FAQPage\"],\"@id\":\"https:\\\/\\\/gigz.pk\\\/php\\\/?lesson=if-else-if-else\",\"url\":\"https:\\\/\\\/gigz.pk\\\/php\\\/?lesson=if-else-if-else\",\"name\":\"if, else if, else - Learn PHP with GiGz.PK\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/gigz.pk\\\/php\\\/#website\"},\"datePublished\":\"2026-05-20T07:44:28+00:00\",\"dateModified\":\"2026-05-21T14:37:55+00:00\",\"description\":\"Learn if else if else statements in web development with PHP and JavaScript examples, logic flow, and real world website usage guide\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/gigz.pk\\\/php\\\/?lesson=if-else-if-else#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/gigz.pk\\\/php\\\/?lesson=if-else-if-else\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/gigz.pk\\\/php\\\/?lesson=if-else-if-else#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/gigz.pk\\\/php\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"PHP Fundamentals (Beginner Level) > Operators and Conditions > if, else if, else\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/gigz.pk\\\/php\\\/#website\",\"url\":\"https:\\\/\\\/gigz.pk\\\/php\\\/\",\"name\":\"Learn PHP with GiGz.PK\",\"description\":\"\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/gigz.pk\\\/php\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"if, else if, else - Learn PHP with GiGz.PK","description":"Learn if else if else statements in web development with PHP and JavaScript examples, logic flow, and real world website usage guide","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/gigz.pk\/php\/?lesson=if-else-if-else","og_locale":"en_US","og_type":"article","og_title":"if, else if, else - Learn PHP with GiGz.PK","og_description":"Learn if else if else statements in web development with PHP and JavaScript examples, logic flow, and real world website usage guide","og_url":"https:\/\/gigz.pk\/php\/?lesson=if-else-if-else","og_site_name":"Learn PHP with GiGz.PK","article_modified_time":"2026-05-21T14:37:55+00:00","twitter_card":"summary_large_image","twitter_misc":{"Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":["WebPage","FAQPage"],"@id":"https:\/\/gigz.pk\/php\/?lesson=if-else-if-else","url":"https:\/\/gigz.pk\/php\/?lesson=if-else-if-else","name":"if, else if, else - Learn PHP with GiGz.PK","isPartOf":{"@id":"https:\/\/gigz.pk\/php\/#website"},"datePublished":"2026-05-20T07:44:28+00:00","dateModified":"2026-05-21T14:37:55+00:00","description":"Learn if else if else statements in web development with PHP and JavaScript examples, logic flow, and real world website usage guide","breadcrumb":{"@id":"https:\/\/gigz.pk\/php\/?lesson=if-else-if-else#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/gigz.pk\/php\/?lesson=if-else-if-else"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/gigz.pk\/php\/?lesson=if-else-if-else#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/gigz.pk\/php"},{"@type":"ListItem","position":2,"name":"PHP Fundamentals (Beginner Level) > Operators and Conditions > if, else if, else"}]},{"@type":"WebSite","@id":"https:\/\/gigz.pk\/php\/#website","url":"https:\/\/gigz.pk\/php\/","name":"Learn PHP with GiGz.PK","description":"","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/gigz.pk\/php\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"}]}},"_links":{"self":[{"href":"https:\/\/gigz.pk\/php\/index.php?rest_route=\/wp\/v2\/lesson\/69","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/gigz.pk\/php\/index.php?rest_route=\/wp\/v2\/lesson"}],"about":[{"href":"https:\/\/gigz.pk\/php\/index.php?rest_route=\/wp\/v2\/types\/lesson"}],"wp:attachment":[{"href":"https:\/\/gigz.pk\/php\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=69"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}