PHP - mathematische Konstanten
Alle folgenden Werte sind als Konstanten bereits vordefiniert.
| Name | Wert |
|---|---|
| M_PI (Kreiszahl Pi) | 3.1415926535898 |
| M_E (Eulersche Zahl e) | 2.718281828459 |
| M_LOG2E | 1.442695040889 |
| M_LOG10E | 0.43429448190325 |
| M_LN2 | 0.69314718055995 |
| M_LN10 | 2.302585092994 |
| M_PI_2 | 1.5707963267949 |
| M_PI_4 | 0.78539816339745 |
| M_1_PI | 0.31830988618379 |
| M_2_PI | 0.63661977236758 |
| M_2_SQRTPI | 1.1283791670955 |
| M_SQRT2 | 1.4142135623731 |
| M_SQRT1_2 | 0.70710678118655 |
Beispiel
<?php
echo M_PI;
?>
Ergebnis:
3.1415926535898
Beispiel 2
<?php
$radius=5;
echo "Kreisumfang bei Radius $radius: ".(2*$radius*M_PI);
?>
Ergebnis:
Kreisumfang bei Radius 5: 31.415926535898
zurück: PHP - Variablen und Konstanten
Ergänzung? Fehler? Schreib uns an team@phpbox.de
Du findest phpbox.de nützlich? Wir freuen uns über einen Link auf phpbox.de

