PHP Numeric - making a website -

PHP Numeric

PHP 6 Months 100% Job Assistance Program. for more info... call on 8588829328

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. No Function What it Does
1 ceil() Rounds a number up
2 floor() Rounds a number down
3 abs() Finds the absolute value of anumber
4 pow() Raises one number to the power of another
5 exp() Finds the exponent of a number
6 rand() Generates a random number
7 bindec() Converts a number from binary to decimal
8 decbin() Converts a number from decimal to binary
9 decoct() Converts a number from decimal to octal
10 octdec() Converts a number from octal to decimal
11 dechex() Converts a number from decimal to hexadecimal
12 hexdec() Converts a number from hexadecimal to decimal
13 number_format() Formats number with grouped thousands and decimals
14 printf() Formats a number using a custom specification
15 round find round number
16 sqrt find 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

Latest Trending Technologies