PHP - gmp_strval() Function
Definition and Usage
The gmp_strval() function converts given GMP number to a string.
Description
The gmp_strval() converts the GMP number to a string to the base given as input. By default the base is 10.
Syntax
gmp_strval ( GMP $gmpnumber [, int $base = 10 ] ) : string
Parameters
| Sr.No | Parameter & Description |
|---|---|
| 1 |
gmpnumber The gmpnumber you want to convert to string.The gmpnumber can be a GMP resource number , a gmp object or a numeric string. |
| 2 |
base The base you want for the number returned. The default base is 10. The base can take values from 2 to 62 and -2 to -36. |
Return Values
PHP gmp_strval() function returns GMP number as a string.
PHP Version
This function will work from PHP Version greater than 5.0.0.
Example 1
Working of gmp_strval() −
<?php
$a = gmp_init("0x454feccd");
$num = gmp_strval($a);
echo "The decimal value is :".$num;
?>
This will produce following result −
The decimal value is :1162865869
Example 2
Working of gmp_strval() −
<?php
$a = gmp_init("0x454feccd");
$num = gmp_strval($a, 8);
echo "The value with base:8 is :".$num;
?>
This will produce following result −
The value with base:8 is :10523766315
Example 3
Working of gmp_strval() −
<?php
$a = gmp_init("0x454feccd");
$num = gmp_strval($a, 36);
echo "The value with base:36 is :".$num;
?>
This will produce following result −
The value with base:36 is :j8c91p
php_function_reference.htm
Advertisements