PHP - gmp_init() Function
Definition and Usage
The gmp_init() function creates a GMP number.
Description
The gmp_init() function creates a GMP number from a given integer or string.
Syntax
gmp_init ( mixed $number [, int $base = 0 ] ) : GMP
Parameters
| Sr.No | Parameter & Description |
|---|---|
| 1 |
number The number can be a integer or a string value.If string it can be hexadecimal, decimal,octal or binary. |
| 2 |
base The base can take value from 2 to 36. The default value for base is 0 and the actual base is determined by the starting two characters.If the string starts with 0x or 0X, it is considered as hexadecimal, if 0 than octal otherwise decimal. |
Return Values
PHP gmp_init() function returns a GMP number from the given number or string value.
PHP Version
This function will work from PHP Version greater than 5.0.0.
Example 1
Working of gmp_init −
<?php $a = gmp_init(19456); echo "The GMP number is : ".$a; ?>
This will produce following result −
The GMP number is : 19456
Example 2
Working of gmp_init −
<?php
$a = gmp_init('0xb83');
echo "The GMP number is : ".$a;
?>
This will produce following result −
The GMP number is : 2947
Example 3
Working of gmp_init −
<?php
$a = gmp_init('0111', 2);
echo "The GMP number is : ".$a;
?>
This will produce following result −
The GMP number is : 7