PHP Math functions

abs()Absolute value of a number
acos()Arc Cosine value of input
acosh()Inverse hyperbolic cosine of input
asin()Arc Sin value of input
asinh()Inverse hyperbolic sine of input
atan()Arc tangent value of input
atan2()Arc tangent of two inputs
atanh()Inverse hyperbolic tangent value of input
base_convert()Convert number from one base to other
bindec()Decimal equivalent of Binary string
ceil()Next Higher integer after rounding
cos()Cos value of Radian input
cosh()Hyperbolic cosine
decbin()Binary equivalent of Decimal number
dechex()Hex equivalent of Decimal number
decoct()Octal equivalent of Decimal number
deg2rad()Convert Degree value to Radian
exp()Value of e raised to the power of input value
expm1()equivalent to 'exp(arg) - 1'
floor()nearest lower integer
fmod()reminder ( modulo ) of a division
getrandmax()largest random value
hexdec()Hexadecimal to decimal
hypot()hypotenuse of a right-angle triangle
intdiv()integer quotient of the division ( PHP 7 )
is_finite()Checking legal finite number
is_infinite()Checking whether value is infinite
is_nan()Checking whether a value is not a number
lcg_value()pseudo random number generator
log()Log value with different Base
log10()Log value with Base 10
log1p()Log value with input added by 1
max()Maximum value from array or group
min()Minimum value from array or group
mt_getrandmax()largest possible random value
mt_rand()random value generator
mt_srand()Seeds random value generator
octdec()Convert Octal to Decimal number
PI()Constant value PI() & M_PI
POW()Exponential value of a Base
round()Rounded value of a number
rand()Random number generator
random_int()cryptographic random integer generator ( PHP 7)
rad2deg()Convert radian to degree
sin()Sin value of Radian input
sinh()Hyperbolic sine value
sqrt()square root of number
tan()Tangent value of Radian input
tanh()Hyperbolic tangent value

Addition subtraction multiplication & Division

These simple scripts are easy to understand and develop. Let us try with some sample code using these basic mathematical functions.

Generating Random Number

In any game or while generating passwords we use random number generators to give us random numbers.

Formatting numbers

We can format numbers by specifying number of decimal places or use comma ( , ) to mark thousand places or use any other marks in our number formatting

Modulus or reminder of a division

We can get the modulus of two number by using modulus ( % ) function.


Subscribe to our YouTube Channel here


* indicates required
Subscribe to plus2net


    Please give small example and syntax

    Post your comments , suggestion , error , requirements etc here

    PHP video Tutorials
    We use cookies to improve your browsing experience. . Learn more
    HTML MySQL PHP JavaScript ASP Photoshop Articles FORUM . Contact us
    ©2000-2024 All rights reserved worldwide Privacy Policy Disclaimer