PHP sin() Function

In this chapter you will learn:

  1. Definition for PHP sin() Function
  2. Syntax for PHP sin() Function
  3. Parameter for PHP sin() Function
  4. Return for PHP sin() Function
  5. 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

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/*  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:

  1. Definition for PHP sinh() Function
  2. Syntax for PHP sinh() Function
  3. Parameter for PHP sinh() Function
  4. Return for PHP sinh() Function
  5. Example - Return the hyperbolic sine of different numbers