PHP Numeric - making a website -

PHP Numeric

PHP Summer Training/Internship with 2 Live Projects in Noida Fee is only 5500/-Click here to Book Your Seat.


PHP numeric functions

Don’t think that PHP’s power is limited to strings only.

The language has over 50 built-in functions for working with numbers, ranging from simple formatting functions to functions for arithmetic, logarithmic, and trigonometric manipulations.

Some of these important functions are

Sr. NoFunctionWhat it Does
1ceil()Rounds a number up
2floor()Rounds a number down
3abs()Finds the absolute value of anumber
4pow()Raises one number to the power of another
5exp()Finds the exponent of a number
6rand()Generates a random number
7bindec()Converts a number from binary to decimal
8decbin()Converts a number from decimal to binary
9decoct()Converts a number from decimal to octal
10octdec()Converts a number from octal to decimal
11dechex()Converts a number from decimal to hexadecimal
12hexdec()Converts a number from hexadecimal to decimal
13number_format()Formats number with grouped thousands and decimals
14printf()Formats a number using a custom specification
15roundfind round number
16sqrtfind square root of a number

Eg i(ceil)


In the above example
Initialize variable $num with value=19.7 , output will become 20.
because this function round value up.

Eg ii(floor)


in the above example
variable $num = 19.7,and the output will become 19.
Because this function round value down.

Eg iii(abs)


In the above example
declare variable ($num) value=19.7 and the output will 19.7
Because abs( ) returns the absolute of given number.

Eg iv(pow)


In the above example.
Pass pow( ) function inside echo with value(4,3).
Its multiply (value=4). three times and the result is 64.

Eg v(rand)


In the above example
Pass rand( ) function With value from( 10 to 99 ).
it will display any random value lies from 10 to 100.
when we refresh the page on every refresh it show random value like. 22,33 ,44,56 and so on.

Eg vi(bindec)


In the above example
bindec( ) function pass inside echo statement with binary value = 1000.
So output will become 8 because bindec( ) function convert binary number into decimal number.

Eg vii(decbin)


In the above example
decbin( ) function Pass inside echo statement with decimal value = 8.
So output will become. 1000

Keep Updating yourself