{"id":742,"date":"2025-08-01T15:13:39","date_gmt":"2025-08-01T06:13:39","guid":{"rendered":"https:\/\/nexive.tech\/?p=742"},"modified":"2025-08-01T15:13:40","modified_gmt":"2025-08-01T06:13:40","slug":"%e3%80%90%e3%82%b5%e3%82%af%e3%83%83%e3%81%a8%e8%a7%a3%e8%aa%ac%e3%80%91php%e3%81%aeif%e3%83%bbelse%e3%83%bbswitch%e6%a7%8b%e6%96%87%e3%81%a7%e6%9d%a1%e4%bb%b6%e5%88%86%e5%b2%90%e3%81%99%e3%82%8b","status":"publish","type":"post","link":"https:\/\/nexive.tech\/?p=742","title":{"rendered":"\u3010\u30b5\u30af\u30c3\u3068\u89e3\u8aac\u3011PHP\u306eif\u30fbelse\u30fbswitch\u69cb\u6587\u3067\u6761\u4ef6\u5206\u5c90\u3059\u308b\u65b9\u6cd5\u307e\u3068\u3081"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">1. \u672c\u8a18\u4e8b\u306e\u30dd\u30a4\u30f3\u30c8<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>PHP\u306b\u304a\u3051\u308b\u4ee3\u8868\u7684\u306a\u6761\u4ef6\u5206\u5c90\u69cb\u6587\uff08if \/ else \/ switch\uff09\u306e\u4f7f\u3044\u65b9\u3092\u6574\u7406<\/li>\n\n\n\n<li>\u66f8\u304d\u65b9\u306e\u9055\u3044\u3068\u9078\u5b9a\u57fa\u6e96\u3092\u5177\u4f53\u4f8b\u3068\u3068\u3082\u306b\u89e3\u8aac<\/li>\n\n\n\n<li>\u5b9f\u52d9\u3067\u3042\u308a\u304c\u3061\u306a\u8aa4\u7528\u3084\u6ce8\u610f\u70b9\u306b\u3082\u89e6\u308c\u308b<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">2. PHP\u306e\u6761\u4ef6\u5206\u5c90\u69cb\u6587\u3068\u306f\uff1f<\/h2>\n\n\n\n<p>PHP\u3067\u306f\u3001\u6761\u4ef6\u306b\u5fdc\u3058\u3066\u51e6\u7406\u3092\u5206\u3051\u308b\u305f\u3081\u306b\u8907\u6570\u306e\u6761\u4ef6\u5206\u5c90\u69cb\u6587\u304c\u7528\u610f\u3055\u308c\u3066\u3044\u307e\u3059\u3002<br>\u4e3b\u306b\u4ee5\u4e0b\u306e3\u7a2e\u985e\u304c\u4ee3\u8868\u7684\u3067\u3059\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>if \/ elseif \/ else<\/code>\uff1a\u6700\u3082\u67d4\u8edf\u3067\u4e00\u822c\u7684\u306a\u69cb\u6587<\/li>\n\n\n\n<li><code>switch<\/code>\uff1a\u7279\u5b9a\u306e\u5024\u306b\u5fdc\u3058\u305f\u5206\u5c90\u306b\u9069\u3057\u3066\u3044\u308b<\/li>\n\n\n\n<li>\u4e09\u9805\u6f14\u7b97\u5b50\uff08<code>?:<\/code>\uff09\u3084 null\u5408\u4f53\u6f14\u7b97\u5b50\uff08<code>??<\/code>\uff09\u3082\u88dc\u52a9\u7684\u306b\u5229\u7528\u3055\u308c\u308b<\/li>\n<\/ul>\n\n\n\n<p>\u3053\u308c\u3089\u306f\u30e6\u30fc\u30b6\u30fc\u5165\u529b\u306e\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u3001\u30eb\u30fc\u30c6\u30a3\u30f3\u30b0\u5206\u5c90\u3001\u8868\u793a\u5185\u5bb9\u306e\u5207\u308a\u66ff\u3048\u306a\u3069\u3001\u5b9f\u52d9\u4e0a\u983b\u51fa\u3059\u308b\u5236\u5fa1\u30ed\u30b8\u30c3\u30af\u3067\u91cd\u8981\u306a\u5f79\u5272\u3092\u679c\u305f\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">3. \u8a73\u7d30\u89e3\u8aac<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">if \/ else \/ elseif \u306e\u57fa\u672c\u69cb\u6587<\/h3>\n\n\n\n<p>\u8907\u96d1\u306a\u6761\u4ef6\u3084\u8907\u6570\u306e\u5206\u5c90\u304c\u3042\u308b\u5834\u9762\u3067\u4f7f\u7528\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#D4D4D4;--cbp-line-number-width:calc(2 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:flex;align-items:center;padding:16px 0 0 16px;width:100%;text-align:left;background-color:#1e1e1e\"><span style=\"background:#c7c7c7;padding:0.3rem 0.5rem 0.2rem;border-radius:1rem;font-size:0.8em;line-height:1;height:1.25rem;text-align:center;display:inline-flex;align-items:center;justify-content:center;color:#1e1e1e\">PHP<\/span><\/span><span role=\"button\" tabindex=\"0\" style=\"color:#D4D4D4;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><pre class=\"code-block-pro-copy-button-pre\" aria-hidden=\"true\"><textarea class=\"code-block-pro-copy-button-textarea\" tabindex=\"-1\" aria-hidden=\"true\" readonly>&lt;?php\n$score = 75;\n\nif ($score >= 90) {\n    echo \"\u512a\u79c0\";\n} elseif ($score >= 70) {\n    echo \"\u5408\u683c\";\n} else {\n    echo \"\u518d\u8a66\u9a13\";\n}\n\/\/ \u51fa\u529b: \u5408\u683c\n?>\n<\/textarea><\/pre><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki dark-plus\" style=\"background-color: #1E1E1E\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #D4D4D4\">&lt;?php<\/span><\/span>\n<span class=\"line\"><span style=\"color: #9CDCFE\">$score<\/span><span style=\"color: #D4D4D4\"> = <\/span><span style=\"color: #B5CEA8\">75<\/span><span style=\"color: #D4D4D4\">;<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #C586C0\">if<\/span><span style=\"color: #D4D4D4\"> (<\/span><span style=\"color: #9CDCFE\">$score<\/span><span style=\"color: #D4D4D4\"> &gt;= <\/span><span style=\"color: #B5CEA8\">90<\/span><span style=\"color: #D4D4D4\">) {<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">    <\/span><span style=\"color: #DCDCAA\">echo<\/span><span style=\"color: #D4D4D4\"> <\/span><span style=\"color: #CE9178\">&quot;\u512a\u79c0&quot;<\/span><span style=\"color: #D4D4D4\">;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">} <\/span><span style=\"color: #C586C0\">elseif<\/span><span style=\"color: #D4D4D4\"> (<\/span><span style=\"color: #9CDCFE\">$score<\/span><span style=\"color: #D4D4D4\"> &gt;= <\/span><span style=\"color: #B5CEA8\">70<\/span><span style=\"color: #D4D4D4\">) {<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">    <\/span><span style=\"color: #DCDCAA\">echo<\/span><span style=\"color: #D4D4D4\"> <\/span><span style=\"color: #CE9178\">&quot;\u5408\u683c&quot;<\/span><span style=\"color: #D4D4D4\">;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">} <\/span><span style=\"color: #C586C0\">else<\/span><span style=\"color: #D4D4D4\"> {<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">    <\/span><span style=\"color: #DCDCAA\">echo<\/span><span style=\"color: #D4D4D4\"> <\/span><span style=\"color: #CE9178\">&quot;\u518d\u8a66\u9a13&quot;<\/span><span style=\"color: #D4D4D4\">;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">}<\/span><\/span>\n<span class=\"line\"><span style=\"color: #6A9955\">\/\/ \u51fa\u529b: \u5408\u683c<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">?&gt;<\/span><\/span>\n<span class=\"line\"><\/span><\/code><\/pre><\/div>\n\n\n\n<h3 class=\"wp-block-heading\">switch\u6587\u306e\u57fa\u672c\u3068\u4f7f\u3044\u3069\u3053\u308d<\/h3>\n\n\n\n<p>\u7279\u5b9a\u306e\u5024\u306b\u5bfe\u3057\u3066\u5206\u5c90\u51e6\u7406\u3092\u884c\u3046\u5834\u5408\u3001switch\u306e\u65b9\u304c\u8aad\u307f\u3084\u3059\u304f\u306a\u308a\u307e\u3059\u3002<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#D4D4D4;--cbp-line-number-width:calc(2 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:flex;align-items:center;padding:16px 0 0 16px;width:100%;text-align:left;background-color:#1e1e1e\"><span style=\"background:#c7c7c7;padding:0.3rem 0.5rem 0.2rem;border-radius:1rem;font-size:0.8em;line-height:1;height:1.25rem;text-align:center;display:inline-flex;align-items:center;justify-content:center;color:#1e1e1e\">PHP<\/span><\/span><span role=\"button\" tabindex=\"0\" style=\"color:#D4D4D4;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><pre class=\"code-block-pro-copy-button-pre\" aria-hidden=\"true\"><textarea class=\"code-block-pro-copy-button-textarea\" tabindex=\"-1\" aria-hidden=\"true\" readonly>&lt;?php\n$role = \"admin\";\n\nswitch ($role) {\n    case \"admin\":\n        echo \"\u7ba1\u7406\u8005\u753b\u9762\";\n        break;\n    case \"editor\":\n        echo \"\u7de8\u96c6\u8005\u753b\u9762\";\n        break;\n    case \"viewer\":\n        echo \"\u95b2\u89a7\u8005\u753b\u9762\";\n        break;\n    default:\n        echo \"\u4e0d\u660e\u306a\u6a29\u9650\";\n}\n\/\/ \u51fa\u529b: \u7ba1\u7406\u8005\u753b\u9762\n?>\n<\/textarea><\/pre><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki dark-plus\" style=\"background-color: #1E1E1E\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #D4D4D4\">&lt;?php<\/span><\/span>\n<span class=\"line\"><span style=\"color: #9CDCFE\">$role<\/span><span style=\"color: #D4D4D4\"> = <\/span><span style=\"color: #CE9178\">&quot;admin&quot;<\/span><span style=\"color: #D4D4D4\">;<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #C586C0\">switch<\/span><span style=\"color: #D4D4D4\"> (<\/span><span style=\"color: #9CDCFE\">$role<\/span><span style=\"color: #D4D4D4\">) {<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">    <\/span><span style=\"color: #C586C0\">case<\/span><span style=\"color: #D4D4D4\"> <\/span><span style=\"color: #CE9178\">&quot;admin&quot;<\/span><span style=\"color: #D4D4D4\">:<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">        <\/span><span style=\"color: #DCDCAA\">echo<\/span><span style=\"color: #D4D4D4\"> <\/span><span style=\"color: #CE9178\">&quot;\u7ba1\u7406\u8005\u753b\u9762&quot;<\/span><span style=\"color: #D4D4D4\">;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">        <\/span><span style=\"color: #C586C0\">break<\/span><span style=\"color: #D4D4D4\">;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">    <\/span><span style=\"color: #C586C0\">case<\/span><span style=\"color: #D4D4D4\"> <\/span><span style=\"color: #CE9178\">&quot;editor&quot;<\/span><span style=\"color: #D4D4D4\">:<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">        <\/span><span style=\"color: #DCDCAA\">echo<\/span><span style=\"color: #D4D4D4\"> <\/span><span style=\"color: #CE9178\">&quot;\u7de8\u96c6\u8005\u753b\u9762&quot;<\/span><span style=\"color: #D4D4D4\">;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">        <\/span><span style=\"color: #C586C0\">break<\/span><span style=\"color: #D4D4D4\">;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">    <\/span><span style=\"color: #C586C0\">case<\/span><span style=\"color: #D4D4D4\"> <\/span><span style=\"color: #CE9178\">&quot;viewer&quot;<\/span><span style=\"color: #D4D4D4\">:<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">        <\/span><span style=\"color: #DCDCAA\">echo<\/span><span style=\"color: #D4D4D4\"> <\/span><span style=\"color: #CE9178\">&quot;\u95b2\u89a7\u8005\u753b\u9762&quot;<\/span><span style=\"color: #D4D4D4\">;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">        <\/span><span style=\"color: #C586C0\">break<\/span><span style=\"color: #D4D4D4\">;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">    <\/span><span style=\"color: #C586C0\">default<\/span><span style=\"color: #D4D4D4\">:<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">        <\/span><span style=\"color: #DCDCAA\">echo<\/span><span style=\"color: #D4D4D4\"> <\/span><span style=\"color: #CE9178\">&quot;\u4e0d\u660e\u306a\u6a29\u9650&quot;<\/span><span style=\"color: #D4D4D4\">;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">}<\/span><\/span>\n<span class=\"line\"><span style=\"color: #6A9955\">\/\/ \u51fa\u529b: \u7ba1\u7406\u8005\u753b\u9762<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">?&gt;<\/span><\/span>\n<span class=\"line\"><\/span><\/code><\/pre><\/div>\n\n\n\n<h3 class=\"wp-block-heading\">\u4e09\u9805\u6f14\u7b97\u5b50\u3068 null\u5408\u4f53\u6f14\u7b97\u5b50\u306e\u88dc\u8db3<\/h3>\n\n\n\n<p>\u7c21\u5358\u306a\u6761\u4ef6\u3067\u4ee3\u66ff\u5024\u3092\u8fd4\u3059\u3068\u304d\u306b\u4f7f\u3044\u307e\u3059\u3002<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#D4D4D4;--cbp-line-number-width:calc(1 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:flex;align-items:center;padding:16px 0 0 16px;width:100%;text-align:left;background-color:#1e1e1e\"><span style=\"background:#c7c7c7;padding:0.3rem 0.5rem 0.2rem;border-radius:1rem;font-size:0.8em;line-height:1;height:1.25rem;text-align:center;display:inline-flex;align-items:center;justify-content:center;color:#1e1e1e\">PHP<\/span><\/span><span role=\"button\" tabindex=\"0\" style=\"color:#D4D4D4;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><pre class=\"code-block-pro-copy-button-pre\" aria-hidden=\"true\"><textarea class=\"code-block-pro-copy-button-textarea\" tabindex=\"-1\" aria-hidden=\"true\" readonly>&lt;?php\n$age = 20;\necho ($age >= 18) ? \"\u6210\u4eba\" : \"\u672a\u6210\u5e74\"; \/\/ \u6210\u4eba\n\n$name = $_GET&#91;'name'&#93; ?? '\u30b2\u30b9\u30c8';\necho $name; \/\/ \u30af\u30a8\u30ea\u306b name \u304c\u306a\u3044\u5834\u5408\u306f \"\u30b2\u30b9\u30c8\"\n?>\n<\/textarea><\/pre><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki dark-plus\" style=\"background-color: #1E1E1E\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #D4D4D4\">&lt;?php<\/span><\/span>\n<span class=\"line\"><span style=\"color: #9CDCFE\">$age<\/span><span style=\"color: #D4D4D4\"> = <\/span><span style=\"color: #B5CEA8\">20<\/span><span style=\"color: #D4D4D4\">;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #DCDCAA\">echo<\/span><span style=\"color: #D4D4D4\"> (<\/span><span style=\"color: #9CDCFE\">$age<\/span><span style=\"color: #D4D4D4\"> &gt;= <\/span><span style=\"color: #B5CEA8\">18<\/span><span style=\"color: #D4D4D4\">) ? <\/span><span style=\"color: #CE9178\">&quot;\u6210\u4eba&quot;<\/span><span style=\"color: #D4D4D4\"> : <\/span><span style=\"color: #CE9178\">&quot;\u672a\u6210\u5e74&quot;<\/span><span style=\"color: #D4D4D4\">; <\/span><span style=\"color: #6A9955\">\/\/ \u6210\u4eba<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #9CDCFE\">$name<\/span><span style=\"color: #D4D4D4\"> = <\/span><span style=\"color: #9CDCFE\">$_GET<\/span><span style=\"color: #D4D4D4\">&#91;<\/span><span style=\"color: #CE9178\">&#39;name&#39;<\/span><span style=\"color: #D4D4D4\">&#93; ?? <\/span><span style=\"color: #CE9178\">&#39;\u30b2\u30b9\u30c8&#39;<\/span><span style=\"color: #D4D4D4\">;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #DCDCAA\">echo<\/span><span style=\"color: #D4D4D4\"> <\/span><span style=\"color: #9CDCFE\">$name<\/span><span style=\"color: #D4D4D4\">; <\/span><span style=\"color: #6A9955\">\/\/ \u30af\u30a8\u30ea\u306b name \u304c\u306a\u3044\u5834\u5408\u306f &quot;\u30b2\u30b9\u30c8&quot;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">?&gt;<\/span><\/span>\n<span class=\"line\"><\/span><\/code><\/pre><\/div>\n\n\n\n<h3 class=\"wp-block-heading\">if \u3068 switch \u306e\u9078\u5b9a\u57fa\u6e96<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>switch\u304c\u9069\u3059\u308b\u30b1\u30fc\u30b9<\/strong>\uff1a\u6bd4\u8f03\u5bfe\u8c61\u304c\u540c\u3058\u5909\u6570\u3067\u8907\u6570\u306e\u5b9a\u6570\u3068\u4e00\u81f4\u3059\u308b\u304b\u3092\u78ba\u8a8d\u3057\u305f\u3044\u5834\u5408<\/li>\n\n\n\n<li><strong>if\u304c\u9069\u3059\u308b\u30b1\u30fc\u30b9<\/strong>\uff1a\u6761\u4ef6\u5f0f\u304c\u8907\u96d1\u306a\u6bd4\u8f03\u3084\u7bc4\u56f2\u3001\u95a2\u6570\u547c\u3073\u51fa\u3057\u3092\u542b\u3080\u5834\u5408<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">4. \u3088\u304f\u3042\u308b\u30df\u30b9\u30fb\u8aa4\u89e3\u30fb\u843d\u3068\u3057\u7a74<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>switch\u6587\u3067break\u6f0f\u308c<\/strong>\uff1a<code>break<\/code>\u3092\u66f8\u304d\u5fd8\u308c\u308b\u3068\u3001\u6b21\u306ecase\u307e\u3067\u51e6\u7406\u304c\u7d9a\u884c\u3055\u308c\u308b\uff08\u30d5\u30a9\u30fc\u30eb\u30b9\u30eb\u30fc\uff09<\/li>\n\n\n\n<li><strong>\u6761\u4ef6\u306e\u8a55\u4fa1\u9806\u306b\u6ce8\u610f<\/strong>\uff1aif\u6587\u3067\u3088\u308a\u5177\u4f53\u306a\u6761\u4ef6\u3092\u5148\u306b\u66f8\u304b\u306a\u3044\u3068\u3001\u610f\u56f3\u3057\u305f\u5206\u5c90\u306b\u5165\u3089\u306a\u3044\u3053\u3068\u304c\u3042\u308b<\/li>\n\n\n\n<li><strong>\u53b3\u5bc6\u6bd4\u8f03\u3092\u5fd8\u308c\u308b<\/strong>\uff1a<code>==<\/code>\u3067\u306a\u304f<code>===<\/code>\u3092\u4f7f\u308f\u306a\u3044\u3068\u578b\u306e\u9055\u3044\u306b\u8d77\u56e0\u3059\u308b\u8aa4\u52d5\u4f5c\u304c\u8d77\u3053\u308b\u53ef\u80fd\u6027\u304c\u3042\u308b<\/li>\n\n\n\n<li><strong>null\u5408\u4f53\u6f14\u7b97\u5b50\u306e\u5bfe\u8c61\u306b\u6ce8\u610f<\/strong>\uff1a\u672a\u5b9a\u7fa9\u5909\u6570\u3092\u542b\u3080\u3068Notice\u304c\u767a\u751f\u3059\u308b\u53ef\u80fd\u6027\u304c\u3042\u308b<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">5. \u307e\u3068\u3081<\/h2>\n\n\n\n<p>PHP\u306e\u6761\u4ef6\u5206\u5c90\u69cb\u6587\u306f\u3001if\/elseif\/else\u306b\u3088\u308b\u67d4\u8edf\u306a\u6761\u4ef6\u51e6\u7406\u3068\u3001switch\u306b\u3088\u308b\u5024\u6bd4\u8f03\u306e\u52b9\u7387\u5316\u304c\u57fa\u672c\u3067\u3059\u3002<br>\u4e09\u9805\u6f14\u7b97\u5b50\u3084null\u5408\u4f53\u6f14\u7b97\u5b50\u3082\u7c21\u6f54\u306a\u8868\u73fe\u3067\u88dc\u52a9\u7684\u306b\u6d3b\u7528\u3067\u304d\u307e\u3059\u3002<br>\u69cb\u6587\u3054\u3068\u306e\u7279\u6027\u3092\u7406\u89e3\u3057\u3001\u8aa4\u7528\u3092\u907f\u3051\u308b\u3053\u3068\u3067\u3001\u3088\u308a\u5b89\u5168\u3067\u660e\u78ba\u306a\u6761\u4ef6\u51e6\u7406\u304c\u5b9f\u73fe\u3067\u304d\u307e\u3059\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>1. \u672c\u8a18\u4e8b\u306e\u30dd\u30a4\u30f3\u30c8 2. PHP\u306e\u6761\u4ef6\u5206\u5c90\u69cb\u6587\u3068\u306f\uff1f PHP\u3067\u306f\u3001\u6761\u4ef6\u306b\u5fdc\u3058\u3066\u51e6\u7406\u3092\u5206\u3051\u308b\u305f\u3081\u306b\u8907\u6570\u306e\u6761\u4ef6\u5206\u5c90\u69cb\u6587\u304c\u7528\u610f\u3055\u308c\u3066\u3044\u307e\u3059\u3002\u4e3b\u306b\u4ee5\u4e0b\u306e3\u7a2e\u985e\u304c\u4ee3\u8868\u7684\u3067\u3059\uff1a \u3053\u308c\u3089\u306f\u30e6\u30fc\u30b6\u30fc\u5165\u529b\u306e\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u3001\u30eb\u30fc\u30c6\u30a3\u30f3\u30b0 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":445,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"swell_btn_cv_data":"","footnotes":""},"categories":[85],"tags":[],"class_list":["post-742","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-php"],"_links":{"self":[{"href":"https:\/\/nexive.tech\/index.php?rest_route=\/wp\/v2\/posts\/742","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/nexive.tech\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/nexive.tech\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/nexive.tech\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/nexive.tech\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=742"}],"version-history":[{"count":1,"href":"https:\/\/nexive.tech\/index.php?rest_route=\/wp\/v2\/posts\/742\/revisions"}],"predecessor-version":[{"id":743,"href":"https:\/\/nexive.tech\/index.php?rest_route=\/wp\/v2\/posts\/742\/revisions\/743"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/nexive.tech\/index.php?rest_route=\/wp\/v2\/media\/445"}],"wp:attachment":[{"href":"https:\/\/nexive.tech\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=742"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/nexive.tech\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=742"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/nexive.tech\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=742"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}