{"id":9429,"date":"2020-01-24T12:32:25","date_gmt":"2020-01-24T12:32:25","guid":{"rendered":"https:\/\/www.devopsschool.com\/blog\/?p=9429"},"modified":"2022-05-08T12:07:22","modified_gmt":"2022-05-08T12:07:22","slug":"important-conditional-statement-of-php","status":"publish","type":"post","link":"https:\/\/www.devopsschool.com\/blog\/important-conditional-statement-of-php\/","title":{"rendered":"How to declare conditional statements in PHP with example?"},"content":{"rendered":"\n<p><strong>When You write a code different actions for different conditions. Then, You can use Conditional statements in your code to do this.<\/strong><\/p>\n\n\n\n<p><strong>If Statement:-<\/strong><br> If Statement executes some code when one condition is true.<br> ex:-<\/p>\n\n\n\n<script src=\"https:\/\/gist.github.com\/ajcotocus\/9a261482cbdbdc25d63f9674ef0ec367.js\"><\/script>\n\n\n\n<p><strong>If \u2026else Statement:-<br><\/strong> If \u2026. else Statement executes similar if statement when one condition is true and another condition is false.<br> ex:-<\/p>\n\n\n\n<script src=\"https:\/\/gist.github.com\/ajcotocus\/c1108f61c07a181e19123d661da6e456.js\"><\/script>\n\n\n\n<p><strong>If\u2026elseif\u2026else Statement:- <br><\/strong> If\u2026elseif\u2026else Statement executes different codes when for more than than two or multiple codes.<br> ex:- <\/p>\n\n\n\n<script src=\"https:\/\/gist.github.com\/ajcotocus\/cf2f2f2d75274e2389671a4af3cb9c5c.js\"><\/script>\n\n\n\n<p><strong>Switch Statement:-<br><\/strong> Switch Statement executes one of many Statement when true.<br> ex:-<\/p>\n\n\n\n<script src=\"https:\/\/gist.github.com\/ajcotocus\/45654351c4fe10e4aeb07273c5844a87.js\"><\/script>\n\n\n\n<p><strong>If and nested if:-<br><\/strong> If and nested if multiple code executes  when true total statement print and when wrong then wrong statement print.<br> ex:-<\/p>\n\n\n\n<script src=\"https:\/\/gist.github.com\/ajcotocus\/8754e2a6ad31d204302ca195be1e116a.js\"><\/script>\n\n\n\n<p><strong>If\u2026 else\u2026 nested\u2026if:-<\/strong><\/p>\n\n\n\n<script src=\"https:\/\/gist.github.com\/ajcotocus\/11682f00ffda22faa08a6e22e6c9773e.js\"><\/script>\n\n\n<div class=\"epyt-gallery\" data-currpage=\"1\" id=\"epyt_gallery_11521\"><figure class=\"wp-block-embed wp-block-embed-youtube is-type-video is-provider-youtube epyt-figure\"><div class=\"wp-block-embed__wrapper\"><iframe loading=\"lazy\"  id=\"_ytid_43662\"  width=\"760\" height=\"427\"  data-origwidth=\"760\" data-origheight=\"427\" src=\"https:\/\/www.youtube.com\/embed\/?enablejsapi=1&#038;autoplay=0&#038;cc_load_policy=0&#038;cc_lang_pref=&#038;iv_load_policy=1&#038;loop=0&#038;rel=1&#038;fs=1&#038;playsinline=0&#038;autohide=2&#038;theme=dark&#038;color=red&#038;controls=1&#038;disablekb=0&#038;\" class=\"__youtube_prefs__  no-lazyload\" title=\"YouTube player\"  data-epytgalleryid=\"epyt_gallery_11521\"  allow=\"fullscreen; accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" referrerpolicy=\"strict-origin-when-cross-origin\" allowfullscreen data-no-lazy=\"1\" data-skipgform_ajax_framebjll=\"\"><\/iframe><\/div><\/figure><div class=\"epyt-gallery-list\"><div>Sorry, there was a YouTube error.<\/div><\/div><\/div>","protected":false},"excerpt":{"rendered":"<p>When You write a code different actions for different conditions. Then, You can use Conditional statements in your code to do this. If Statement:- If Statement executes some code when one condition is true. ex:- If \u2026else Statement:- If \u2026. else Statement executes similar if statement when one condition is true and another condition is&#8230;<\/p>\n","protected":false},"author":1,"featured_media":9504,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_kad_post_transparent":"","_kad_post_title":"","_kad_post_layout":"","_kad_post_sidebar_id":"","_kad_post_content_style":"","_kad_post_vertical_padding":"","_kad_post_feature":"","_kad_post_feature_position":"","_kad_post_header":false,"_kad_post_footer":false,"_kad_post_classname":"","_joinchat":[],"footnotes":""},"categories":[5150],"tags":[5829,2454,177,5828],"class_list":["post-9429","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-php","tag-conditional","tag-important","tag-php","tag-statement"],"_links":{"self":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/9429","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/comments?post=9429"}],"version-history":[{"count":6,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/9429\/revisions"}],"predecessor-version":[{"id":25000,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/9429\/revisions\/25000"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/media\/9504"}],"wp:attachment":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/media?parent=9429"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/categories?post=9429"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/tags?post=9429"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}