Open In App

PHP | gmp_import() Function

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:

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

Article Tags :