{"id":2648,"date":"2021-07-20T08:45:42","date_gmt":"2021-07-20T08:45:42","guid":{"rendered":"https:\/\/www.bearloga.space\/?page_id=2648"},"modified":"2021-07-20T08:45:43","modified_gmt":"2021-07-20T08:45:43","slug":"operator-switch-v-php","status":"publish","type":"page","link":"https:\/\/www.bearloga.space\/uk\/operator-switch-v-php\/","title":{"rendered":"\u041e\u043f\u0435\u0440\u0430\u0442\u043e\u0440 SWITCH \u0432 PHP"},"content":{"rendered":"\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<p class=\"wp-block-paragraph\">\u0418\u043d\u043e\u0433\u0434\u0430 \u0434\u0430\u0436\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0438 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u043e\u0432&nbsp;<code><a href=\"https:\/\/php720.com\/lesson\/14\" target=\"_blank\" rel=\"noopener\">if<\/a><\/code>&nbsp;..&nbsp;<code><a href=\"https:\/\/php720.com\/lesson\/18\" target=\"_blank\" rel=\"noopener\">elseif<\/a><\/code>&nbsp;\u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0443\u0442\u043e\u043c\u043b\u044f\u0435\u0442.<br>\u0427\u0442\u043e\u0431\u044b \u0438\u0441\u043f\u0440\u0430\u0432\u0438\u0442\u044c \u044d\u0442\u0443 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u044e \u0435\u0441\u0442\u044c \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440&nbsp;<code>switch<\/code>. \u0421\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><strong>switch<\/strong> (exp) \n{\n    <strong>case<\/strong> condition1:\n    exp1;\n    <strong>break<\/strong>;\n    \n    <strong>case<\/strong> condition2:\n    exp2;\n    <strong>break<\/strong>;\n    \n    <strong>case<\/strong> condition3:\n    exp3;\n    <strong>break<\/strong>;\n    \n    <strong>default<\/strong>:\n    exp4;\n    <strong>break<\/strong>;\n}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043a\u043b\u044e\u0447\u0435\u0432\u043e\u0435 \u0441\u043b\u043e\u0432\u043e&nbsp;<code>switch<\/code>, \u043f\u043e\u0441\u043b\u0435 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0432 \u0441\u043a\u043e\u0431\u043a\u0430\u0445 \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0435.<br>\u0414\u0430\u043b\u0435\u0435, \u043f\u043e\u0441\u043b\u0435 \u0441\u043b\u043e\u0432\u0430&nbsp;<code>case<\/code>&nbsp;\u043d\u0443\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u0438\u0442\u044c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u0435 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u044b \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439, \u0435\u0441\u043b\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0438\u0441\u0442\u0438\u043d\u0430, \u0442\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u0433\u0440\u0443\u043f\u043f\u0430 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0437\u0430\u043f\u0438\u0441\u0430\u043d\u044b \u0434\u043e \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u0430&nbsp;<code>break<\/code>. \u0415\u0441\u043b\u0438 \u043d\u0438 \u043e\u0434\u043d\u043e \u0443\u0441\u043b\u043e\u0432\u0438\u0435 \u043d\u0435 \u043f\u043e\u0434\u0445\u043e\u0434\u0438\u0442, \u0442\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440&nbsp;<code>default<\/code>&nbsp;(\u0435\u0441\u043b\u0438 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440&nbsp;<code>default<\/code>&nbsp;\u043d\u0435 \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c, \u0442\u043e \u043f\u0440\u0438 \u043d\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0438 \u043d\u0438\u043a\u0430\u043a\u0438\u0445 \u0434\u0440\u0443\u0433\u0438\u0445 \u0443\u0441\u043b\u043e\u0432\u0438\u0439 \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435 \u043f\u0440\u043e\u0438\u0437\u043e\u0439\u0434\u0435\u0442).<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;?php\n$speed = 55;\n\n<strong>switch<\/strong>($speed)\n{\n    <strong>case<\/strong> 30 : \n        <strong>echo<\/strong> \"\u0412\u0430\u0448\u0430 \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u044c 30 \u043a\u043c\/\u0447\u0430\u0441\";\n    <strong>break<\/strong>;\n    \n    <strong>case<\/strong> 58 : \n        <strong>echo<\/strong> \"\u0412\u0430\u0448\u0430 \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u044c 50 \u043a\u043c\/\u0447\u0430\u0441\";\n    <strong>break<\/strong>;\n    \n    <strong>case<\/strong> 70 : \n        <strong>echo<\/strong> \"\u041f\u0440\u0435\u0432\u044b\u0448\u0435\u043d\u0438\u0435 \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u0438 !\";\n    <strong>break<\/strong>;\n    \n    <strong>default<\/strong> : \n        <strong>echo<\/strong> \"\u0421\u043a\u043e\u0440\u043e\u0441\u0442\u044c \u0432 \u043f\u0440\u0435\u0434\u0435\u043b\u0430\u0445 \u043d\u043e\u0440\u043c\u044b\";\n    <strong>break<\/strong>;\n\n}\n?&gt;<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u0422\u0430\u043a\u0436\u0435, \u043f\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u0430&nbsp;<code>switch<\/code>, \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0437\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0443\u0441\u043b\u043e\u0432\u0438\u0439 \u0434\u043b\u044f \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;?php\n$speed = 55;\n\n<strong>switch<\/strong>($speed)\n{\n    <strong>case<\/strong> 30 : \n    <strong>case<\/strong> 58 : \n        <strong>echo<\/strong> \"\u0421\u043a\u043e\u0440\u043e\u0441\u0442\u044c \u0432 \u043f\u0440\u0435\u0434\u0435\u043b\u0430\u0445 \u043d\u043e\u0440\u043c\u044b\";\n    <strong>break<\/strong>;\n    \n    <strong>case<\/strong> 70 : \n        <strong>echo<\/strong> \"\u041f\u0440\u0435\u0432\u044b\u0448\u0435\u043d\u0438\u0435 \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u0438 !\";\n    <strong>break<\/strong>;\n    \n    <strong>default<\/strong> : \n        <strong>echo<\/strong> \"\u0421\u043a\u043e\u0440\u043e\u0441\u0442\u044c \u0432 \u043f\u0440\u0435\u0434\u0435\u043b\u0430\u0445 \u043d\u043e\u0440\u043c\u044b\";\n    <strong>break<\/strong>;\n\n}\n?&gt;<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u0412 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u043c\u044b \u0443\u0432\u0438\u0434\u0438\u043c \u2014 &#8220;\u0421\u043a\u043e\u0440\u043e\u0441\u0442\u044c \u0432 \u043f\u0440\u0435\u0434\u0435\u043b\u0430\u0445 \u043d\u043e\u0440\u043c\u044b&#8221;.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u0418\u043d\u043e\u0433\u0434\u0430 \u0434\u0430\u0436\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0438 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u043e\u0432&nbsp;if&nbsp;..&nbsp;elseif&nbsp;\u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0443\u0442\u043e\u043c\u043b\u044f\u0435\u0442.\u0427\u0442\u043e\u0431\u044b \u0438\u0441\u043f\u0440\u0430\u0432\u0438\u0442\u044c \u044d\u0442\u0443 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u044e \u0435\u0441\u0442\u044c \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440&nbsp;switch. \u0421\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441: \u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043a\u043b\u044e\u0447\u0435\u0432\u043e\u0435 \u0441\u043b\u043e\u0432\u043e&nbsp;switch, \u043f\u043e\u0441\u043b\u0435 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0432 \u0441\u043a\u043e\u0431\u043a\u0430\u0445 [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"categories":[100],"tags":[],"class_list":["post-2648","page","type-page","status-publish","hentry","category-onlajn-uchebnik-po-php"],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.bearloga.space\/uk\/wp-json\/wp\/v2\/pages\/2648","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.bearloga.space\/uk\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/www.bearloga.space\/uk\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/www.bearloga.space\/uk\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.bearloga.space\/uk\/wp-json\/wp\/v2\/comments?post=2648"}],"version-history":[{"count":0,"href":"https:\/\/www.bearloga.space\/uk\/wp-json\/wp\/v2\/pages\/2648\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.bearloga.space\/uk\/wp-json\/wp\/v2\/media?parent=2648"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.bearloga.space\/uk\/wp-json\/wp\/v2\/categories?post=2648"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.bearloga.space\/uk\/wp-json\/wp\/v2\/tags?post=2648"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}