What is cosh() in PHP?
The cosh() function in PHP returns the hyperbolic cosine of a number in radians.
The following illustration shows the mathematical representation of the cosh() function.
Syntax
cosh(float $num): float
Parameter
As a parameter, this function requires a number that represents an angle in radians.
To convert degrees to radians, use the following formula.
radians = degrees * ( M_PI / 180.0 )
Return value
cosh() returns the hyperbolic cosine of a number (in radians) that is sent in as a parameter.
-
If the value of
numis , then the return value isNaN not a number NaN. -
If the value of
numis positive/negative infinity, then the return value ispositive infinity.
Code
<?php#Positive number in radiansecho("cosh(2.3): ");echo (cosh(2.3));?><?php#Negative number in radiansecho("cosh(-2.3): ");echo (cosh(-2.3));?><?php#converting the degrees angle into radians and then applying cosh()#degrees = 180echo("cosh(180 * (M_PI / (180))): ");echo (cosh(180 * (M_PI / (180))));?>