{"id":1163,"date":"2014-10-20T11:14:44","date_gmt":"2014-10-20T11:14:44","guid":{"rendered":"http:\/\/www.webhozz.com\/blog\/?p=1163"},"modified":"2014-11-22T03:58:20","modified_gmt":"2014-11-22T03:58:20","slug":"perbedaan-antara-struktur-if-dengan-switch","status":"publish","type":"post","link":"https:\/\/www.webhozz.com\/blog\/perbedaan-antara-struktur-if-dengan-switch\/","title":{"rendered":"Perbedaan Antara struktur IF dengan Switch"},"content":{"rendered":"<p><a href=\"http:\/\/www.webhozz.com\/blog\/wp-content\/uploads\/2014\/10\/iforswitch.jpg\"><img fetchpriority=\"high\" decoding=\"async\" class=\"size-full wp-image-1164 aligncenter\" src=\"http:\/\/www.webhozz.com\/blog\/wp-content\/uploads\/2014\/10\/iforswitch.jpg\" alt=\"iforswitch\" width=\"600\" height=\"442\" srcset=\"https:\/\/www.webhozz.com\/blog\/wp-content\/uploads\/2014\/10\/iforswitch.jpg 600w, https:\/\/www.webhozz.com\/blog\/wp-content\/uploads\/2014\/10\/iforswitch-300x221.jpg 300w\" sizes=\"(max-width: 600px) 100vw, 600px\" \/><\/a><\/p>\n<p>Dalam PHP, jika kita ingin memberikan suatu pernyataan atau kondisi namun bersyarat atau lebih mudah nya ingin menyatakan suatu perbandingan , bisa gunakan perbandingan IF atau SWITCH. Dua &#8211; duanya memiliki tujuan yang sama , hanya saja terdapat perbedaan yakni terletak pada struktur penulisan kode , adapun perbedaan lainnya antara lain sebagai berikut :<\/p>\n<p><!--more--><\/p>\n<p>1. Switch : di awal perintah hanya satu kali akan memeriksa suatu kondisi sedangkan IF : akan memeriksa disetiap kondisi.\u00a0Sehingga jika anda memiliki struktur percabangan yang banyak, struktur switch akan lebih cepat dieksekusi.<\/p>\n<p>2. Switch : \u00a0operasi perbandingan yang dilakukan terbatas, misalnya\u00a0\u00a0untuk hal-hal sederhana seperti memeriksa nilai dari sebuah variabel berbeda dengan IF.<\/p>\n<p>3. Switch : tidak bisa digunakan untuk percabangan program dengan operasi yang lebih rumit seperti membandingkan 2 variabel. Kita tidak bisa menggunakan switch untuk membuat kode program menentukan nilai terbesar Sedangkan IF bisa.<\/p>\n<p>Sehingga dalam berbagai kasus akan sering menggunakan IF.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Dalam PHP, jika kita ingin memberikan suatu pernyataan atau kondisi namun bersyarat atau lebih mudah nya ingin menyatakan suatu perbandingan , bisa gunakan perbandingan IF<\/p>\n","protected":false},"author":9,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[287,16,239,288,241,126,240,289,218],"class_list":["post-1163","post","type-post","status-publish","format-standard","hentry","category-belajar-web-programming","tag-belajar-membuat-if-switch","tag-belajar-php","tag-if","tag-if-adalah","tag-perbandingan","tag-php","tag-switch","tag-switch-adalah","tag-web-programming"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.3 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Perbedaan Antara struktur IF dengan Switch - WebHozz Blog<\/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:\/\/www.webhozz.com\/blog\/perbedaan-antara-struktur-if-dengan-switch\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Perbedaan Antara struktur IF dengan Switch - WebHozz Blog\" \/>\n<meta property=\"og:description\" content=\"Dalam PHP, jika kita ingin memberikan suatu pernyataan atau kondisi namun bersyarat atau lebih mudah nya ingin menyatakan suatu perbandingan , bisa gunakan perbandingan IF\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.webhozz.com\/blog\/perbedaan-antara-struktur-if-dengan-switch\/\" \/>\n<meta property=\"og:site_name\" content=\"WebHozz Blog\" \/>\n<meta property=\"article:published_time\" content=\"2014-10-20T11:14:44+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2014-11-22T03:58:20+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.webhozz.com\/blog\/wp-content\/uploads\/2014\/10\/iforswitch.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"600\" \/>\n\t<meta property=\"og:image:height\" content=\"442\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.webhozz.com\\\/blog\\\/perbedaan-antara-struktur-if-dengan-switch\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.webhozz.com\\\/blog\\\/perbedaan-antara-struktur-if-dengan-switch\\\/\"},\"author\":{\"name\":\"admin\",\"@id\":\"https:\\\/\\\/www.webhozz.com\\\/blog\\\/#\\\/schema\\\/person\\\/ad1c5822a60b5b228c5ceda20e439fea\"},\"headline\":\"Perbedaan Antara struktur IF dengan Switch\",\"datePublished\":\"2014-10-20T11:14:44+00:00\",\"dateModified\":\"2014-11-22T03:58:20+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.webhozz.com\\\/blog\\\/perbedaan-antara-struktur-if-dengan-switch\\\/\"},\"wordCount\":144,\"publisher\":{\"@id\":\"https:\\\/\\\/www.webhozz.com\\\/blog\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/www.webhozz.com\\\/blog\\\/perbedaan-antara-struktur-if-dengan-switch\\\/#primaryimage\"},\"thumbnailUrl\":\"http:\\\/\\\/www.webhozz.com\\\/blog\\\/wp-content\\\/uploads\\\/2014\\\/10\\\/iforswitch.jpg\",\"keywords\":[\"belajar membuat if switch\",\"Belajar PHP\",\"if\",\"if adalah\",\"perbandingan\",\"php\",\"switch\",\"switch adalah\",\"web programming\"],\"articleSection\":[\"Belajar Web Programming\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.webhozz.com\\\/blog\\\/perbedaan-antara-struktur-if-dengan-switch\\\/\",\"url\":\"https:\\\/\\\/www.webhozz.com\\\/blog\\\/perbedaan-antara-struktur-if-dengan-switch\\\/\",\"name\":\"Perbedaan Antara struktur IF dengan Switch - WebHozz Blog\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.webhozz.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.webhozz.com\\\/blog\\\/perbedaan-antara-struktur-if-dengan-switch\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.webhozz.com\\\/blog\\\/perbedaan-antara-struktur-if-dengan-switch\\\/#primaryimage\"},\"thumbnailUrl\":\"http:\\\/\\\/www.webhozz.com\\\/blog\\\/wp-content\\\/uploads\\\/2014\\\/10\\\/iforswitch.jpg\",\"datePublished\":\"2014-10-20T11:14:44+00:00\",\"dateModified\":\"2014-11-22T03:58:20+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.webhozz.com\\\/blog\\\/perbedaan-antara-struktur-if-dengan-switch\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.webhozz.com\\\/blog\\\/perbedaan-antara-struktur-if-dengan-switch\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.webhozz.com\\\/blog\\\/perbedaan-antara-struktur-if-dengan-switch\\\/#primaryimage\",\"url\":\"http:\\\/\\\/www.webhozz.com\\\/blog\\\/wp-content\\\/uploads\\\/2014\\\/10\\\/iforswitch.jpg\",\"contentUrl\":\"http:\\\/\\\/www.webhozz.com\\\/blog\\\/wp-content\\\/uploads\\\/2014\\\/10\\\/iforswitch.jpg\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.webhozz.com\\\/blog\\\/perbedaan-antara-struktur-if-dengan-switch\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.webhozz.com\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Perbedaan Antara struktur IF dengan Switch\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.webhozz.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/www.webhozz.com\\\/blog\\\/\",\"name\":\"WebHozz Blog\",\"description\":\"Kursus Web &amp; Android di Jakarta Bandung\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.webhozz.com\\\/blog\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.webhozz.com\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.webhozz.com\\\/blog\\\/#organization\",\"name\":\"WebHozz\",\"url\":\"https:\\\/\\\/www.webhozz.com\\\/blog\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.webhozz.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.webhozz.com\\\/blog\\\/wp-content\\\/uploads\\\/2018\\\/04\\\/logo-persegi.jpg\",\"contentUrl\":\"https:\\\/\\\/www.webhozz.com\\\/blog\\\/wp-content\\\/uploads\\\/2018\\\/04\\\/logo-persegi.jpg\",\"width\":442,\"height\":442,\"caption\":\"WebHozz\"},\"image\":{\"@id\":\"https:\\\/\\\/www.webhozz.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.webhozz.com\\\/blog\\\/#\\\/schema\\\/person\\\/ad1c5822a60b5b228c5ceda20e439fea\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/bff35e4083f3870e2f911c4437e788147d340f274268d361dd7e1cf20bebb156?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/bff35e4083f3870e2f911c4437e788147d340f274268d361dd7e1cf20bebb156?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/bff35e4083f3870e2f911c4437e788147d340f274268d361dd7e1cf20bebb156?s=96&d=mm&r=g\",\"caption\":\"admin\"},\"url\":\"https:\\\/\\\/www.webhozz.com\\\/blog\\\/author\\\/putralucio\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Perbedaan Antara struktur IF dengan Switch - WebHozz Blog","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:\/\/www.webhozz.com\/blog\/perbedaan-antara-struktur-if-dengan-switch\/","og_locale":"en_US","og_type":"article","og_title":"Perbedaan Antara struktur IF dengan Switch - WebHozz Blog","og_description":"Dalam PHP, jika kita ingin memberikan suatu pernyataan atau kondisi namun bersyarat atau lebih mudah nya ingin menyatakan suatu perbandingan , bisa gunakan perbandingan IF","og_url":"https:\/\/www.webhozz.com\/blog\/perbedaan-antara-struktur-if-dengan-switch\/","og_site_name":"WebHozz Blog","article_published_time":"2014-10-20T11:14:44+00:00","article_modified_time":"2014-11-22T03:58:20+00:00","og_image":[{"width":600,"height":442,"url":"https:\/\/www.webhozz.com\/blog\/wp-content\/uploads\/2014\/10\/iforswitch.jpg","type":"image\/jpeg"}],"author":"admin","twitter_card":"summary_large_image","twitter_misc":{"Written by":"admin","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.webhozz.com\/blog\/perbedaan-antara-struktur-if-dengan-switch\/#article","isPartOf":{"@id":"https:\/\/www.webhozz.com\/blog\/perbedaan-antara-struktur-if-dengan-switch\/"},"author":{"name":"admin","@id":"https:\/\/www.webhozz.com\/blog\/#\/schema\/person\/ad1c5822a60b5b228c5ceda20e439fea"},"headline":"Perbedaan Antara struktur IF dengan Switch","datePublished":"2014-10-20T11:14:44+00:00","dateModified":"2014-11-22T03:58:20+00:00","mainEntityOfPage":{"@id":"https:\/\/www.webhozz.com\/blog\/perbedaan-antara-struktur-if-dengan-switch\/"},"wordCount":144,"publisher":{"@id":"https:\/\/www.webhozz.com\/blog\/#organization"},"image":{"@id":"https:\/\/www.webhozz.com\/blog\/perbedaan-antara-struktur-if-dengan-switch\/#primaryimage"},"thumbnailUrl":"http:\/\/www.webhozz.com\/blog\/wp-content\/uploads\/2014\/10\/iforswitch.jpg","keywords":["belajar membuat if switch","Belajar PHP","if","if adalah","perbandingan","php","switch","switch adalah","web programming"],"articleSection":["Belajar Web Programming"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/www.webhozz.com\/blog\/perbedaan-antara-struktur-if-dengan-switch\/","url":"https:\/\/www.webhozz.com\/blog\/perbedaan-antara-struktur-if-dengan-switch\/","name":"Perbedaan Antara struktur IF dengan Switch - WebHozz Blog","isPartOf":{"@id":"https:\/\/www.webhozz.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.webhozz.com\/blog\/perbedaan-antara-struktur-if-dengan-switch\/#primaryimage"},"image":{"@id":"https:\/\/www.webhozz.com\/blog\/perbedaan-antara-struktur-if-dengan-switch\/#primaryimage"},"thumbnailUrl":"http:\/\/www.webhozz.com\/blog\/wp-content\/uploads\/2014\/10\/iforswitch.jpg","datePublished":"2014-10-20T11:14:44+00:00","dateModified":"2014-11-22T03:58:20+00:00","breadcrumb":{"@id":"https:\/\/www.webhozz.com\/blog\/perbedaan-antara-struktur-if-dengan-switch\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.webhozz.com\/blog\/perbedaan-antara-struktur-if-dengan-switch\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.webhozz.com\/blog\/perbedaan-antara-struktur-if-dengan-switch\/#primaryimage","url":"http:\/\/www.webhozz.com\/blog\/wp-content\/uploads\/2014\/10\/iforswitch.jpg","contentUrl":"http:\/\/www.webhozz.com\/blog\/wp-content\/uploads\/2014\/10\/iforswitch.jpg"},{"@type":"BreadcrumbList","@id":"https:\/\/www.webhozz.com\/blog\/perbedaan-antara-struktur-if-dengan-switch\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.webhozz.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Perbedaan Antara struktur IF dengan Switch"}]},{"@type":"WebSite","@id":"https:\/\/www.webhozz.com\/blog\/#website","url":"https:\/\/www.webhozz.com\/blog\/","name":"WebHozz Blog","description":"Kursus Web &amp; Android di Jakarta Bandung","publisher":{"@id":"https:\/\/www.webhozz.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.webhozz.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.webhozz.com\/blog\/#organization","name":"WebHozz","url":"https:\/\/www.webhozz.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.webhozz.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/www.webhozz.com\/blog\/wp-content\/uploads\/2018\/04\/logo-persegi.jpg","contentUrl":"https:\/\/www.webhozz.com\/blog\/wp-content\/uploads\/2018\/04\/logo-persegi.jpg","width":442,"height":442,"caption":"WebHozz"},"image":{"@id":"https:\/\/www.webhozz.com\/blog\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/www.webhozz.com\/blog\/#\/schema\/person\/ad1c5822a60b5b228c5ceda20e439fea","name":"admin","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/bff35e4083f3870e2f911c4437e788147d340f274268d361dd7e1cf20bebb156?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/bff35e4083f3870e2f911c4437e788147d340f274268d361dd7e1cf20bebb156?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/bff35e4083f3870e2f911c4437e788147d340f274268d361dd7e1cf20bebb156?s=96&d=mm&r=g","caption":"admin"},"url":"https:\/\/www.webhozz.com\/blog\/author\/putralucio\/"}]}},"_links":{"self":[{"href":"https:\/\/www.webhozz.com\/blog\/wp-json\/wp\/v2\/posts\/1163","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.webhozz.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.webhozz.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.webhozz.com\/blog\/wp-json\/wp\/v2\/users\/9"}],"replies":[{"embeddable":true,"href":"https:\/\/www.webhozz.com\/blog\/wp-json\/wp\/v2\/comments?post=1163"}],"version-history":[{"count":1,"href":"https:\/\/www.webhozz.com\/blog\/wp-json\/wp\/v2\/posts\/1163\/revisions"}],"predecessor-version":[{"id":1165,"href":"https:\/\/www.webhozz.com\/blog\/wp-json\/wp\/v2\/posts\/1163\/revisions\/1165"}],"wp:attachment":[{"href":"https:\/\/www.webhozz.com\/blog\/wp-json\/wp\/v2\/media?parent=1163"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.webhozz.com\/blog\/wp-json\/wp\/v2\/categories?post=1163"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.webhozz.com\/blog\/wp-json\/wp\/v2\/tags?post=1163"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}