This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision | ||
en:dev:all:psr:psr-2 [26.05.2015 19:49] – [Methoden- und Funktionsaufrufe] renamed and translated mrbaseman | en:dev:all:psr:psr-2 [26.05.2015 20:09] – [while, do while] translated mrbaseman | ||
---|---|---|---|
Line 234: | Line 234: | ||
</ | </ | ||
- | ===== Kontrollstrukturen | + | ===== Control Structures |
- | Für alle Kontrollstrukturen gelten erst einmal folgende, allgemeine Regeln: | + | The general style rules for control structures are as follows: |
- | * Es MUSS ein Leerzeichen hinter dem Schlüsselwort der Kontrollstruktur sein. | + | * There MUST be one space after the control structure keyword |
- | * Es DARF NICHT ein Leerzeichen nach der öffnenden Klammer stehen. | + | * There MUST NOT be a space after the opening parenthesis |
- | * Es DARF NICHT ein Leerzeichen vor der schließenden Klammer stehen. | + | * There MUST NOT be a space before the closing parenthesis |
- | * Es MUSS ein Leerzeichen zwischen der schließenden Klammer und der öffnenden, geschweiften Klammer stehen. | + | * There MUST be one space between the closing parenthesis and the opening brace |
- | * Der Strukturkörper MUSS um eine Stufe eingerückt werden. | + | * The structure body MUST be indented once |
- | * Die schließende, | + | * The closing brace MUST be on the next line after the body |
- | Der Körper einer Struktur MUSS in geschweifte Klammern eingeschlossen werden. Diese Standardisierung verhindert Fehler, falls zufällig Leerzeilen im Körper eingefügt werden. | + | The body of each structure MUST be enclosed by braces. This standardizes how the structures look, and reduces the likelihood of introducing errors as new lines get added to the body. |
- | + | ||
- | + | ||
==== if, elseif, else ==== | ==== if, elseif, else ==== | ||
- | Eine **if**-Struktur sieht wie nachfolgend aus. Beachten Sie die Plazierung von Klammern, Leerstellen und geschweiften Klammern. Die Schlüsselwörter | + | An **if** |
<PHP> | <PHP> | ||
if ($expr1) { | if ($expr1) { | ||
Line 257: | Line 254: | ||
} | } | ||
</ | </ | ||
- | Das Schlüsselwort | + | The keyword |
- | + | ||
==== switch, case ==== | ==== switch, case ==== | ||
- | Eine **switch**-Struktur sieht wie nachfolgend aus. Beachten Sie die Plazierung von Klammern, Leerstellen und geschweiften Klammern. | + | A **switch** |
- | Das **case**-Statement MUSS eine Stufe ab **switch** | + | |
<PHP> | <PHP> | ||
switch ($expr) { | switch ($expr) { | ||
Line 281: | Line 275: | ||
} | } | ||
</ | </ | ||
- | |||
- | |||
==== while, do while ==== | ==== while, do while ==== | ||
- | Ein **while**-Statement sieht wie nachfolgend aus. Beachten Sie die Plazierung von Klammern, Leerstellen und geschweiften Klammern. | + | A **while** |
<PHP> | <PHP> | ||
while ($expr) { | while ($expr) { | ||
Line 291: | Line 283: | ||
} | } | ||
</ | </ | ||
- | ebenso sieht ein **do while**-Statement wie nachfolgend aus. Beachten Sie die Plazierung von Klammern, Leerstellen und geschweiften Klammern. | + | Similarly, a **do while** |
<PHP> | <PHP> | ||
do { | do { | ||
Line 297: | Line 289: | ||
} while ($expr); | } while ($expr); | ||
</ | </ | ||
- | |||
- | |||
==== for ==== | ==== for ==== |