Found 33676 Articles for Programming

PHP decoct() Function

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

126 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

PHP dechex() Function

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

186 Views

Definition and UsageThe dechex() function returns a string that contains hexadecimal equivalent of given decimal number argument.This function returns a string with hexadecimal characters.Syntaxdechex ( int $number ) : stringParametersSr.NoParameter & Description1numberA decimal number to be converted in equivalent hexadecimal representationReturn ValuesPHP dechex() function returns a hexadecimal 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 '3e9' −OutputThis will produce following result −dechex(1001) = 3e9Example Live DemoFollowing example shows that fractional part of given number is ignored. Hence 100.55 is treated as 100 ... Read More

PHP decbin() Function

Malhar Lathkar
Updated on 29-Jun-2020 08:40:45

246 Views

Definition and UsageThe decbin() function returns a string that contains binary equivalent of given decimal number argument.This function returns a string with binary digits.Syntaxdecbin ( int $number ) : stringParametersSr.NoParameter & Description1numberA decimal number to be converted in equivalent binary representationReturn ValuesPHP decbin() function returns a binary 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 13 and returns '1101' −OutputThis will produce following result −decbin(13) = 1101Example Live DemoFollowing example shows that fractional part of given number is ignored. Hence 9.99 is treated as 9 ... Read More

PHP cosh() Function

Malhar Lathkar
Updated on 29-Jun-2020 08:39:01

221 Views

Definition and UsageThe cosh() function returns the hyperbolic cosine ratio of given angle in radians. In trigonometry, hyperbolic cosine ratio is defined as .cosh(x) = (ex – e-x))/2This function returns a float value .Syntaxcosh ( float $arg ) : floatParametersSr.NoParameter & Description1argA floating point value that represents angle in radiansReturn ValuesPHP cosh() function returns hyperbolic cosine ratio of 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 calculates cosh(pi/2) and returns 2.5091784786581 which is also the result of formula (ex + e-x))/2 −OutputThis will produce following result −cosh(M_PI_2) = 2.5091784786581 ... Read More

PHP cos() Function

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

340 Views

Definition and UsageThe cos() function returns the cosine ratio of given angle in radians. In trigonometry, cosine of an angle is defined as ratio of lengths of adjacent side and hypotenuse.cos(x) = adjacent/hypotenuseIf x=90 degree, cos(x) = 0.This function returns a float value.Syntaxcos ( float $arg ) : floatParametersSr.NoParameter & Description1argA floating point value that represents angle in radiansReturn ValuesPHP cos() function returns cosine ratio of 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 calculates cos(pi/2) and returns 6.1232339957368E-17 (very close to 0). Cosine ratio of 90 deg is ... Read More

PHP ceil() Function

Malhar Lathkar
Updated on 29-Jun-2020 08:35:17

347 Views

Definition and UsageThe ceil() function is an in-built function in PHP iterpreter. This function accepts any float number as argument and rounds it up to the next highest integer.This function always returns a float number as range of float is bigger than that of integer.Syntaxceil ( float $num ) : floatParametersSr.NoParameter & Description1numThe number to be rounded up.Return ValuesPHP ceil() function returns the smallest integer value that is bigger 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 5.78 to its next highest integer which ... Read More

PHP bindec() Function

Malhar Lathkar
Updated on 29-Jun-2020 08:34:02

232 Views

Definition and UsageThe bindec() function returns decinmal equivalent of a binary number represented as a string argument. Binary number inside string is interpreted as unigned integer.This function returns a decimal integer. However, it may return float for size reasons.Syntaxbindec ( string $binary_string ) : numberParametersSr.NoParameter & Description1binary_stringA string containing binary number representation. Invalid characters (other than 1 and 0) are ignored.Return ValuesPHP bindec() function returns decimal equivalent of given binary 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 decimal equivalent of '1101' and returns 13 −Read More

PHP base_convert() Function

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

503 Views

Definition and UsageThe base_convert() function is versatile utility to convert a number with one base to another. The base is not restricted to binary, octal, hexadecimal or decimal. It can be any number between 2 and 36.First argument to this function is a string that can contain alpha-numeric characters. Digits in a number with base>9 will be represented by alphabets a - z such that 10 is represented by 'a', 11 by 'b' upto 35 by 'z'For example base_convert('1001', 2, 10) converts '1001' from binary to decimal number which is 9Syntaxbase_convert ( string $number , int $frombase , int $tobase ... Read More

PHP atanh() Function

Malhar Lathkar
Updated on 29-Jun-2020 08:29:17

217 Views

Definition and UsageThe atanh() function returns the inverse hyperbolic tangent ratio of given given parameter. In other words, the return value of atanh() is hyperbolic tangent of given parameter. A inverse hyperbolic tangent function is defined as .atanh(x) = 0.5Xlog((1+x)/(1-x))This function returns a float value .Syntaxatanh ( float $arg ) : floatParametersSr.NoParameter & Description1argA floating point value whose inverse hyperbolic tangent is to be calculatedReturn ValuesPHP atanh() function returns inverse hyperbolic tangent ratio of 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 calculates atanh(pi/4) and returns which is also ... Read More

PHP atan2() Function

Malhar Lathkar
Updated on 29-Jun-2020 08:29:52

241 Views

Definition and UsageThe atan2() function calculates arc tan of two variablesatan2(y, x) returns the arc tangent of the two numbers x and y. although it is similar to atan(y)/atan(x), the signs of both x and y are used to determine the quadrant of the result. Accordingly for values of x and y atan2() isatan(y/x) if x>0atan(y/x)+pi if x>0atan(y/x)-pi if xOutputThis will produce following result −atan2(5, -5) = 2.3561944901923Example Live DemoFollowing program computes atan2(5, 0) and returns 1.570796326795 (M_PI_2) −OutputThis will produce following result −atan2(5, 0) = 1.5707963267949Example Live DemoFollowing example computes atan2(0, 0) and returns 0OutputThis will produce following result −atan2(0, 0) ... Read More

Advertisements