Bifalgorithm post · Computer science one · Generalized Rounding

How do optional and default function parameters work in PHP?

How do optional and default function parameters work in PHP? (Computer science one · Generalized Rounding) — "7 8 //apr will be 0.05, terms will be 60 9 $x = g…

Ideas in this flowchart

  • Verwendung von getMonthlyPayment mit optionalen oder Standardparametern
  • Aufruf mit den Argumenten 10000, 0.05 und 60
  • Der Zinssatz beträgt 0.05 und die Laufzeit 60 Monate
  • Die monatliche Zahlung beträgt 188.71
  • Aufruf von getMonthlyPayment() ohne Argumente
  • Die Standardwerte sind balance 0, APR 0.05 und Laufzeit 60
  • Das Ergebnis ist 0, zusätzlich wird eine Warnung ausgegeben
  • Das Weglassen nur des zweiten Arguments ist nicht möglich
  • Die Bereitstellung von n Argumenten entspricht den ersten n Parametern
  • Optionale oder Standardparameter sollten am Ende der Parameterliste stehen
Feed/

How do optional and default function parameters work in PHP?

No cover

Channel

Computer science one

1 page

"7 8 //apr will be 0.05, terms will be 60 9 $x = getMonthlyPayment(10000); 10 print $x.\n\n\\\"; //188.71 11 12 //balance will be null (0), apr will be 0.05, terms will be 60 13 $x = getMonthlyPayment(); 14 print $x.\n\n\\\"; //0 but also a warning It would not be possible to invoke getMonthlyPayment() by omitting only the second argument. Providing n arguments will match the first n parameters. Thus, in your function design you should place any optional/default parameters last."

Flowchart preview
👍
0
0 comments0 shares

Sign in to view and post comments.