PHP Tutorial - PHP sin() Function






Definition

The sin() function calculates the sine value.

Syntax

PHP sin() Function has the following syntax.

float sin ( float num )

Parameter

ParameterDescription
numberRequired. 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/*  ww w  .j  av a  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.