w3resource

PHP: cos() function

Description

The cos() function is used to get the cosine of a number.

Version:

(PHP 4 and above)

Syntax:

cos(num)

Parameter:

Name Description Required /
Optional
Type
num A number. Required Float

Return value:

The cosine of num.

Value Type: Float.

Pictorial Presentation

php-math-abc()

Example:


 <?php$val1= 0;$val2=4;$val3=-4;$zcos1=cos($val1);$zcos2=cos($val2);$zcos3=cos($val3);echo 
 "Cosine of $val1 is $zcos1
 <br /> ";echo "Cosine of $val2 is $zcos2<br />"
 ;echo "Cosine of $val3 is $zcos3<br />";?>

Output:

Cosine of 0 is 1
 Cosine of 4 is -0.653643620864
 Cosine of -4 is -0.653643620864
 

View the example in the browser

See also

PHP Function Reference

Previous: ceil
Next: cosh



Become a Patron!

Follow us on Facebook and Twitter for latest update.

It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.

https://www.w3resource.com/php/function-reference/cos.php