PHP deg2rad() 函数
PHP deg2rad是一个预定义函数,用于将角度转换为弧度。
语法
float deg2rad ( float $number );
上述给定的函数将度转换为弧度单位。
参数 | 描述 | 必需/可选 |
---|---|---|
number | 指定要转换的度数 | 必需 |
示例1
<?php
degree=15;
echo "Your degree number is : ".degree."<br>";
echo "By using 'deg2rad()' function, your radian equivalent is :".deg2rad($degree);
?>
输出:
Your degree number is : 15
By using 'deg2rad()' function, your radian equivalent is :0.26179938779915
示例2
<?php
degree=45;
echo "Your Degree number is : ".degree."<br>";
echo "By using 'deg2rad()' function, your radian equivalent is :".deg2rad($degree);
?>
输出:
Your Degree number is : 45
By using 'deg2rad()' function, your radian equivalent is :0.78539816339745
示例3
<?php
degree=45;
echo "Your Degree number is : ".degree."<br>";
echo var_dump(deg2rad($degree) === M_PI_4); // Return true
?>
输出:
Your Degree number is : 45
bool(true)
示例4
<?php
degree=180;
echo "Your degree number is : ".degree."<br>";
rad = deg2rad(degree);
echo "degree degrees is equal torad radians.";
?>
输出:
Your degree number is : 180
180 degrees is equal to 3.1415926535898 radians.