From 0cd8496ad002c179390246c6009b74173a10db5c Mon Sep 17 00:00:00 2001 From: NirvashPrime <37520562+NirvashPrime@users.noreply.github.com> Date: Mon, 15 Oct 2018 23:57:51 -0400 Subject: [PATCH] Added fall-through documentation & return notation (#19428) * Added fall-through documentation & return notation Fall-through is an important feature of switch statements. In addition, best practices with break-usage have been included. * fix: added closing switch curly braces * fix: corrected link syntax --- .../pages/guide/english/php/switch/index.md | 61 ++++++++++++++++++- 1 file changed, 59 insertions(+), 2 deletions(-) diff --git a/client/src/pages/guide/english/php/switch/index.md b/client/src/pages/guide/english/php/switch/index.md index 4d4ef2d908..a7d9be04ca 100644 --- a/client/src/pages/guide/english/php/switch/index.md +++ b/client/src/pages/guide/english/php/switch/index.md @@ -19,7 +19,8 @@ In PHP, the `Switch` statement is very similar to the Javascript `Switch` statem echo "i is camp"; break; default: - echo "i is freecodecamp"; + echo "i is freecodecamp"; + break; } ``` @@ -27,5 +28,61 @@ In PHP, the `Switch` statement is very similar to the Javascript `Switch` statem ### Break The `break;` statement exits the switch and goes on to run the rest of the application's code. If you do not use the `break;` statement you may end up running mulitple cases and statements, sometimes this may be desired in which case you should not include the `break;` statement. +An example of this behavior can be seen below: + +``` +php.net docs Switch +* [php.net docs Switch](https://secure.php.net/manual/en/control-structures.switch.php")