Found 1060 Articles for PHP

PHP intdiv() Function

Malhar Lathkar
Updated on 29-Jun-2020 09:00:19

74 Views

Definition and UsageThe intdiv() function returns integer quotient of two integer parameters. If  x/y results in i as division and r as remainder so thatx = y*i+r In this case,  intdiv(x, y) returns i Syntaxintdiv ( int $x , int $y ) : int ParametersSr.NoParameter & Description1xThis parameter forms numerator part of division expression2yThis parameter forms denominator part of division expressionReturn ValuesPHP intdiv() function returns integer quotient of division of x by y. The return value is positive if both parameters are positive or both parameters are negative.PHP VersionThis function is available in PHP versions 4.x, PHP 5.x as well as PHP 7.x.Example Live ... Read More

PHP hypot() Function

Malhar Lathkar
Updated on 29-Jun-2020 08:59:14

178 Views

Definition and UsageThe hypot() function calculates length of hypotenus of a right angled triangle. Hypoteneuse is calculated as per following formula −h=sqrt(x2+y2) where x and y are other two sides of a right angled triangleFor example, if x=3 and y=4, hypot(x, y)=5 which is equal to sqrt(32+42) = sqrt(25) =5This function always returns a float.Syntaxhypot ( float $x , float $y ) : floatParametersSr.NoParameter & Description1xone side of right angled triangle2yother side of right angled triangleReturn ValuesPHP hypot() function returns length of hypotenuse of a right angled triangle with given values of x and yPHP VersionThis function is available in ... Read More

PHP hexdec() Function

Malhar Lathkar
Updated on 29-Jun-2020 08:57:15

125 Views

Definition and UsageThe hexdec() function returns a decimal number equivalent of a hexadecimal number embedded in a string.This function returns a a decimal integer, though larger values may result in floats.Syntaxhexdec ( string $hex_string ) : numberParametersSr.NoParameter & Description1hex_stringA decimal number to be converted in equivalent octal representationReturn ValuesPHP hexdec() function returns a decimal number.PHP VersionThis function is available in PHP versions 4.x, PHP 5.x as well as PHP 7.x.Example Live DemoFollowing example calculates decimal equivalent of '100' and returns 256 −OutputThis will produce following result −hexdec(100) = 256Example Live DemoIf the string contains invalid characters (other than 0-9 and a-f) they ... Read More

PHP getrandmax() Function

Malhar Lathkar
Updated on 29-Jun-2020 08:54:47

203 Views

Definition and UsageThe getrandmax() function returns largest integer that can be used in PHP. Value returned by this function serves as the upper limit for rand() function to generate random number.This function always returns an integer.Syntaxgetrandmax ( void ) : intParametersSr.NoParameter & Description1This function needs no parametersReturn ValuesPHP getrandmax() function returns largest possible integer that can be used in PHP. On 64 bit Windows, the number is 2147483647PHP VersionThis function is available in PHP versions 4.x, PHP 5.x as well as PHP 7.x.Example Live DemoFollowing example returns largest possible integer−OutputThis may produce following result (it being a random number, it is ... Read More

PHP fmod() Function

Malhar Lathkar
Updated on 29-Jun-2020 08:53:16

245 Views

Definition and UsageThe name fmod stands for floating modulo . This function returns remainder of division of two floating point numbers. If  x/y results in i as division and r as remainder so thatx = y*i+r In this case,  fmod(x, y) returns rSyntaxfmod ( float $x , float $y ) : float ParametersSr.NoParameter & Description1xThis parameter forms numerator part of division expression2yThis parameter forms denominator part of division expressionReturn ValuesPHP fmod() function returns floating point remainder of the act of division of x by y. Remainder carries sign of x.PHP VersionThis function is available in PHP versions 4.x, PHP 5.x as ... Read More

PHP floor() Function

Malhar Lathkar
Updated on 29-Jun-2020 08:51:42

751 Views

Definition and UsageThe floor() function is another in-built function in PHP iterpreter. This function accepts any float number as argument and rounds it down to the next lowest integer.This function always returns a float number as range of float is bigger than that of integer.Syntaxfloor ( float $num ) : floatParametersSr.NoParameter & Description1numThe number to be rounded down.Return ValuesPHP floor() function returns the largest integer less than or equal to given parameter.PHP VersionThis function is available in PHP versions 4.x, PHP 5.x as well as PHP 7.x.Example Live DemoFollowing example rounds 15.05 to its next highest integer which is 15OutputThis will ... Read More

PHP expm1() Function

Malhar Lathkar
Updated on 29-Jun-2020 08:49:09

84 Views

Definition and UsageThe expm1() function returns exp(number) - 1, computed in a way that is accurate even when the value of number is close to zero, a case where 'exp (number) - 1' would be inaccurate due to subtraction of two numbers that are nearly equal.expm1(x) = exp(x) - 1This function returns a float value .Syntaxexpm1 ( float $arg ) : floatParametersSr.NoParameter & Description1argA floating point number whose expm1 is to be calculated.Return ValuesPHP expm1() function returns a floating point value.PHP VersionThis function is available in PHP versions 4.x, PHP 5.x as well as PHP 7.x.Example Live DemoFollowing example calculates expm1(2) ... Read More

PHP exp() Function

Malhar Lathkar
Updated on 29-Jun-2020 08:47:31

158 Views

Definition and UsageThe exp() function calculates exponent of e that is Euler Number. PHP has a predefined constant M_E that represents Euler Number and is equal to 2.7182818284590452354. Hence, exp(x) returns 2.7182818284590452354xThis function always returns a float.Syntaxexp ( float $arg ) : floatParametersSr.NoParameter & Description1arga floating point number to raise e toReturn ValuesPHP exp() function returns the Euler Number e raised to given arg. Note that e is base of natural algorithm. The exp() function is inverse of natural logarithm.Hence, if logex = y, then ey=xPHP VersionThis function is available in PHP versions 4.x, PHP 5.x as well as PHP ... Read More

PHP deg2rad() Function

Malhar Lathkar
Updated on 29-Jun-2020 08:46:07

237 Views

Definition and UsageMost trigonometric functions like sin, cos, tan etc require angle argument in radians. The deg2rad() function proves useful in conversion of degrees to radians.This function returns a float number such that number=deg2rad(x) where is angle in degrees. angle in radian = angle in deg *180/piFor example deg2rad(30) is equal to 0.5235987755983 radiansSyntaxdeg2rad ( float $number ) : floatParametersSr.NoParameter & Description1numberA float number reprsenting angle in degreesReturn ValuesPHP deg2rad() function returns a float number that represents angle in radians.PHP VersionThis function is available in PHP versions 4.x, PHP 5.x as well as PHP 7.x.Example Live DemoFollowing example calculates radian equivalent ... Read More

PHP decoct() Function

Malhar Lathkar
Updated on 29-Jun-2020 08:44:20

124 Views

Definition and UsageThe decoct() function returns a string that contains octal equivalent of given decimal number argument.This function returns a string with octal characters (0 to 7).Syntaxdecoct ( int $number ) : stringParametersSr.NoParameter & Description1numberA decimal number to be converted in equivalent octal representationReturn ValuesPHP decoct() function returns an octal number inside string.PHP VersionThis function is available in PHP versions 4.x, PHP 5.x as well as PHP 7.x.Example Live DemoFollowing example calculates binary equivalent of 1001 and returns '1751' −OutputThis will produce following result −decoct(1001) = 1751Example Live DemoFollowing example shows that fractional part of given number is ignored. Hence 100.55 is ... Read More

Advertisements