

{"id":135469,"date":"2024-06-11T10:42:20","date_gmt":"2024-06-11T05:12:20","guid":{"rendered":"https:\/\/data-flair.training\/blogs\/?p=135469"},"modified":"2024-06-11T10:42:20","modified_gmt":"2024-06-11T05:12:20","slug":"php-switch-statement","status":"publish","type":"post","link":"https:\/\/data-flair.training\/blogs\/php-switch-statement\/","title":{"rendered":"PHP Switch Statement"},"content":{"rendered":"<h3>Program 1<\/h3>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">&lt;html&gt;\r\n    &lt;head&gt;&lt;title&gt;PHP Relational Operators&lt;\/title&gt;\r\n    &lt;body&gt;\r\n     &lt;center&gt;\r\n  \r\n&lt;?php\r\n$ch='B';\r\n switch($ch)\r\n{\r\n     case 'a': \r\n     case 'e': \r\n     case 'i':\r\n     case 'o':\r\n     case 'u':\r\n     case 'A': \r\n     case 'E': \r\n     case 'I':\r\n     case 'O':\r\n    case 'U': echo \"VOWEL\"; break;  \r\n    default:echo \"consonent\";\r\n}\r\n\/\/   $n=3;\r\n\/\/   switch($n)\r\n\/\/   {\r\n\/\/     case 1:echo \"One\";break;\r\n\/\/     case 5:echo \"Five\";break;\r\n\/\/     case 4:echo \"Four\";break;\r\n\/\/     case 2:echo \"Two\";break;\r\n\/\/     case 3:echo \"Three\";break;\r\n\/\/     default:echo \"Invalid Number\";\r\n\/\/   }\r\n\r\n  \/*\r\n     switch(value)\r\n     {\r\n        case 1: break;\r\n        case 2:\r\n        case 3:   \r\n        default:\r\n     }\r\n       \/\/ Vowel Chracter\r\n  *\/\r\n     \r\n?&gt;\r\n&lt;\/center&gt;\r\n&lt;\/body&gt;\r\n&lt;\/html&gt;<\/pre>\n<h3>Program 2<\/h3>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">&lt;html&gt;\r\n    &lt;head&gt;&lt;title&gt;PHP Switch case &lt;\/title&gt;\r\n    &lt;body&gt;\r\n     &lt;center&gt;\r\n&lt;?php\r\n    echo \"&lt;br&gt;&lt;font color=red size=5&gt;------------Menu---------------&lt;\/font&gt;\";\r\n    echo \"&lt;br&gt;&lt;font color=Blue size=5&gt;1.Addition&lt;\/font&gt;\";\r\n    echo \"&lt;br&gt;&lt;font color=Blue size=5&gt;2.Swap&lt;\/font&gt;\";\r\n    echo \"&lt;br&gt;&lt;font color=Blue size=5&gt;3.Max between two number&lt;\/font&gt;\";\r\n    echo \"&lt;br&gt;&lt;font color=red size=5&gt;---------------------------------&lt;\/font&gt;\";\r\n    $choice=3;\r\n    switch($choice)\r\n    {\r\n       case 1 :\r\n       {\r\n          $a=50;\r\n          $b=20;\r\n          $c=$a+$b;\r\n          echo \"&lt;br&gt;Addition of \".$a.\" and \".$b.\" is \".$c;\r\n          break;\r\n       }\r\n       case 2: \r\n        {\r\n               $a=50;\r\n               $b=20;\r\n        echo \"&lt;br&gt;Before Sawping \".$a.\" and \".$b;\r\n        $c=$a;\r\n        $a=$b;\r\n        $b=$c;\r\n        echo \"&lt;br&gt;After Sawping \".$a.\" and \".$b;\r\n        break;\r\n        }\r\n       case 3:\r\n        {\r\n              $a=70;\r\n              $b=30;\r\n              $c=$a+$b;\r\n              echo \"&lt;br&gt;bAddition of \".$a. \" and \".$b.\" is \".$c; \r\n              break;\r\n        } \r\n        default: echo \"Invalid choice\";\r\n    }\r\n    \r\n    \r\n    \r\n        \r\n    \r\n    \r\n    \r\n?&gt;\r\n&lt;\/center&gt;\r\n&lt;\/body&gt;\r\n&lt;\/html&gt;<\/pre>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Program 1 &lt;html&gt; &lt;head&gt;&lt;title&gt;PHP Relational Operators&lt;\/title&gt; &lt;body&gt; &lt;center&gt; &lt;?php $ch=&#8217;B&#8217;; switch($ch) { case &#8216;a&#8217;: case &#8216;e&#8217;: case &#8216;i&#8217;: case &#8216;o&#8217;: case &#8216;u&#8217;: case &#8216;A&#8217;: case &#8216;E&#8217;: case &#8216;I&#8217;: case &#8216;O&#8217;: case &#8216;U&#8217;: echo &#8220;VOWEL&#8221;;&#46;&#46;&#46;<\/p>\n","protected":false},"author":86671,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[31445],"tags":[21772,32332,32333,32369,32364,32368,32367,32366,32365],"class_list":["post-135469","post","type-post","status-publish","format-standard","hentry","category-php-tutorials","tag-php","tag-php-practical","tag-php-program","tag-php-switch-case-statement","tag-php-switch-statement","tag-switch-case-statement-in-php","tag-switch-conditional-statement-in-php","tag-switch-statement","tag-switch-statement-in-php"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>PHP Switch Statement - DataFlair<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/data-flair.training\/blogs\/php-switch-statement\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"PHP Switch Statement - DataFlair\" \/>\n<meta property=\"og:description\" content=\"Program 1 &lt;html&gt; &lt;head&gt;&lt;title&gt;PHP Relational Operators&lt;\/title&gt; &lt;body&gt; &lt;center&gt; &lt;?php $ch=&#039;B&#039;; switch($ch) { case &#039;a&#039;: case &#039;e&#039;: case &#039;i&#039;: case &#039;o&#039;: case &#039;u&#039;: case &#039;A&#039;: case &#039;E&#039;: case &#039;I&#039;: case &#039;O&#039;: case &#039;U&#039;: echo &quot;VOWEL&quot;;&#046;&#046;&#046;\" \/>\n<meta property=\"og:url\" content=\"https:\/\/data-flair.training\/blogs\/php-switch-statement\/\" \/>\n<meta property=\"og:site_name\" content=\"DataFlair\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/DataFlairWS\/\" \/>\n<meta property=\"article:published_time\" content=\"2024-06-11T05:12:20+00:00\" \/>\n<meta name=\"author\" content=\"TechVidvan Team\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@DataFlairWS\" \/>\n<meta name=\"twitter:site\" content=\"@DataFlairWS\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"TechVidvan Team\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"PHP Switch Statement - DataFlair","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:\/\/data-flair.training\/blogs\/php-switch-statement\/","og_locale":"en_US","og_type":"article","og_title":"PHP Switch Statement - DataFlair","og_description":"Program 1 &lt;html&gt; &lt;head&gt;&lt;title&gt;PHP Relational Operators&lt;\/title&gt; &lt;body&gt; &lt;center&gt; &lt;?php $ch='B'; switch($ch) { case 'a': case 'e': case 'i': case 'o': case 'u': case 'A': case 'E': case 'I': case 'O': case 'U': echo \"VOWEL\";&#46;&#46;&#46;","og_url":"https:\/\/data-flair.training\/blogs\/php-switch-statement\/","og_site_name":"DataFlair","article_publisher":"https:\/\/www.facebook.com\/DataFlairWS\/","article_published_time":"2024-06-11T05:12:20+00:00","author":"TechVidvan Team","twitter_card":"summary_large_image","twitter_creator":"@DataFlairWS","twitter_site":"@DataFlairWS","twitter_misc":{"Written by":"TechVidvan Team","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/data-flair.training\/blogs\/php-switch-statement\/#article","isPartOf":{"@id":"https:\/\/data-flair.training\/blogs\/php-switch-statement\/"},"author":{"name":"TechVidvan Team","@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/person\/0e594f928e31fc96628ac40f6ae74f49"},"headline":"PHP Switch Statement","datePublished":"2024-06-11T05:12:20+00:00","mainEntityOfPage":{"@id":"https:\/\/data-flair.training\/blogs\/php-switch-statement\/"},"wordCount":6,"commentCount":0,"publisher":{"@id":"https:\/\/data-flair.training\/blogs\/#organization"},"keywords":["PHP","php practical","php program","php switch case statement","php switch statement","switch case statement in php","switch conditional statement in php","switch statement","switch statement in php"],"articleSection":["PHP Tutorials"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/data-flair.training\/blogs\/php-switch-statement\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/data-flair.training\/blogs\/php-switch-statement\/","url":"https:\/\/data-flair.training\/blogs\/php-switch-statement\/","name":"PHP Switch Statement - DataFlair","isPartOf":{"@id":"https:\/\/data-flair.training\/blogs\/#website"},"datePublished":"2024-06-11T05:12:20+00:00","breadcrumb":{"@id":"https:\/\/data-flair.training\/blogs\/php-switch-statement\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/data-flair.training\/blogs\/php-switch-statement\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/data-flair.training\/blogs\/php-switch-statement\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Blog Home","item":"https:\/\/data-flair.training\/blogs\/"},{"@type":"ListItem","position":2,"name":"PHP Tutorials","item":"https:\/\/data-flair.training\/blogs\/category\/php-tutorials\/"},{"@type":"ListItem","position":3,"name":"PHP Switch Statement"}]},{"@type":"WebSite","@id":"https:\/\/data-flair.training\/blogs\/#website","url":"https:\/\/data-flair.training\/blogs\/","name":"DataFlair","description":"Learn Today. Lead Tomorrow.","publisher":{"@id":"https:\/\/data-flair.training\/blogs\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/data-flair.training\/blogs\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/data-flair.training\/blogs\/#organization","name":"DataFlair","url":"https:\/\/data-flair.training\/blogs\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/logo\/image\/","url":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2016\/07\/Data-Flair.png","contentUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2016\/07\/Data-Flair.png","width":106,"height":48,"caption":"DataFlair"},"image":{"@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/DataFlairWS\/","https:\/\/x.com\/DataFlairWS","https:\/\/www.linkedin.com\/company\/dataflair-web-services-pvt-ltd\/","https:\/\/www.youtube.com\/user\/DataFlairWS"]},{"@type":"Person","@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/person\/0e594f928e31fc96628ac40f6ae74f49","name":"TechVidvan Team","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/c89190da3d4010c71ba476b618ab10fdc2335c82cdfa0ad5002d98d0f2473444?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/c89190da3d4010c71ba476b618ab10fdc2335c82cdfa0ad5002d98d0f2473444?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/c89190da3d4010c71ba476b618ab10fdc2335c82cdfa0ad5002d98d0f2473444?s=96&d=mm&r=g","caption":"TechVidvan Team"},"description":"TechVidvan Team provides high-quality content &amp; courses on AI, ML, Data Science, Data Engineering, Data Analytics, programming, Python, DSA, Android, Flutter, full stack web dev, MERN, and many latest technology.","url":"https:\/\/data-flair.training\/blogs\/author\/test001\/"}]}},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts\/135469","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/users\/86671"}],"replies":[{"embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/comments?post=135469"}],"version-history":[{"count":3,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts\/135469\/revisions"}],"predecessor-version":[{"id":142643,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts\/135469\/revisions\/142643"}],"wp:attachment":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/media?parent=135469"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/categories?post=135469"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/tags?post=135469"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}