PHP sin() Function
In this chapter you will learn:
- Definition for PHP sin() Function
- Syntax for PHP sin() Function
- Parameter for PHP sin() Function
- Return for PHP sin() Function
- Example - Return the sine of different numbers
Definition
The sin()
function calculates the sine value.
Syntax
PHP sin() Function has the following syntax.
float sin ( float num )
Parameter
Parameter | Description |
---|---|
number | Required. Specifies a value in radians |
The parameter should be passed as radians.
We should use deg2rad()
to convert degrees to radians.
Return
PHP sin() Function returns the sine value.
Example
Return the sine of different numbers
<?php/* ja va 2 s. co m*/
echo(sin(3) . "\n");
echo(sin(-3) . "\n");
echo(sin(0) . "\n");
echo(sin(M_PI) . "\n");
echo(sin(M_PI_2) . "\n");
$sin1 = sin(10);
print($sin1);
print "\n";
$sin2 = sin(deg2rad(80));
print($sin2);
?>
The code above generates the following result.
Next chapter...
What you will learn in the next chapter:
- Definition for PHP sinh() Function
- Syntax for PHP sinh() Function
- Parameter for PHP sinh() Function
- Return for PHP sinh() Function
- Example - Return the hyperbolic sine of different numbers
Home » PHP Tutorial » PHP Math Functions