programmieren:grundlagen:kontrollstrukturen
Differences
This shows you the differences between two versions of the page.
| programmieren:grundlagen:kontrollstrukturen [2026/07/31 09:23] – created admin | programmieren:grundlagen:kontrollstrukturen [2026/09/23 14:13] (current) – control structures admin | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| - | kontrollstrukturen | + | ====== Control Structures ====== |
| + | |||
| + | Control structures in programming are like the structures that let you define how code should operate. Its basically the most important thing of programming languages. | ||
| + | |||
| + | For example the control structure '' | ||
| + | |||
| + | <code php> | ||
| + | // This case is true since 2+2 does infact equal 4 | ||
| + | if ((2+2) === 4) { | ||
| + | echo 'This will be echoed'; | ||
| + | } | ||
| + | </ | ||
| + | |||
| + | The whole list of PHP Control Structures is found on the official [[https:// | ||
| + | |||
| + | ===== goto ===== | ||
| + | |||
| + | A less common control structure in PHP that I just found out about is goto. | ||
| + | |||
| + | What it does is pretty self explanatory. The code flow, after hitting a '' | ||
| + | |||
| + | Like so: | ||
| + | |||
| + | <code php> | ||
| + | |||
| + | goto after; | ||
| + | |||
| + | echo 'Wont be echoed'; | ||
| + | |||
| + | after: | ||
| + | |||
| + | echo 'Will be echoed'; | ||
| + | |||
| + | </ | ||
| + | |||
| + | I feel like theres a use for it only very rarely, like if you would like to skip a certain code part in a certain condition, if that somehow isn't possible by returning early, or any other means. | ||
| + | |||
| + | I also think it's more useful in procedural programming than Object Oriented. | ||
programmieren/grundlagen/kontrollstrukturen.txt · Last modified: by admin
