The gmp_import() function is an inbuilt function in php which imports a GMP number(GNU Multiple Precision: For large numbers) from a binary string.
Syntax:
GMP gmp_import ( string $data, int $word_size, int $options )
Parameters: The gmp_import() function accepts three parameters as mentioned above and described below:
- $data: It is one of the required parameters, contains the binary string which is supposed to be imported.
- $word_size: This is also a parameter of the gmp_import() function. It contains the number of bytes in each chunk of binary data. This parameter is mainly used simultaneously with the options parameter. The default value of this parameter is 1.
- $options: This parameter has default value of GMP_MSW_FIRST | GMP_NATIVE_ENDIAN.
Return Value: The function returns a GMP number on success otherwise returns FALSE on failure.
Below programs illustrate the gmp_import() function in PHP:
Program 1:
<?php // php code implementing gmp_import() // function $number = gmp_import("\0"); // The gmp_strval() returns the // string value of the gmp number echo gmp_strval($number) . "\n"; ?> |
Output:
0
Program 2:
<?php // php code implementing the // gmp_import() function $number = gmp_import("\0\1\2"); // The strval() returns the string // value of the gmp number echo gmp_strval($number) . "\n"; ?> |
Output:
258
Related Articles:
Reference: php.net/manual/en/function.gmp-import.php
Recommended Posts:
- How to get the function name inside a function in PHP ?
- PHP 5 vs PHP 7
- PHP | Get PHP configuration information using phpinfo()
- PHP | php.ini File Configuration
- How to import config.php file in a PHP script ?
- PHP | imagecreatetruecolor() Function
- PHP | fpassthru( ) Function
- PHP | ImagickDraw getTextAlignment() Function
- PHP | Ds\Sequence last() Function
- PHP | Imagick floodFillPaintImage() Function
- Function to escape regex patterns before applied in PHP
- PHP | array_udiff_uassoc() Function
- PHP | geoip_continent_code_by_name() Function
- PHP | GmagickPixel setcolor() function
- PHP | opendir() Function
- PHP | cal_to_jd() Function
- PHP | stream_get_transports() Function
- PHP | Ds\Deque pop() Function
- PHP | SimpleXMLElement children() Function
- PHP | array_intersect_ukey() Function
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.

