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/*from  w ww  .  j av  a2 s  . c o  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.





















Home »
  PHP Tutorial »
    Function reference »




PHP Array Functions
PHP Calendar Functions
PHP Class Functions
PHP Data Type Functions
PHP Date Functions
PHP File Functions
PHP Image Functions
PHP Math Functions
PHP MySQLi Functions
PHP SimpleXML Functions
PHP String Functions
PHP XML Functions
PHP Zip Functions