• PHP Video Tutorials

PHP - gmp_export() Functions



Definition and Usage

The gmp_export() function exports to a binary string.

Description

gmp_export() will convert the GMP number to binary string.

Syntax

gmp_export ( GMP $gmpnumber [, int $word_size = 1 [, int $options = GMP_MSW_FIRST | GMP_NATIVE_ENDIAN ]] ) : string

Parameters

Sr.No Parameter & Description
1

gmpnumber

The GMP number you want to export to binary string.

2

word_size

The default word size is 1.The number of bytes to be shown in each chunk of binary data.It works along with the Options parameter.

3

options

Default value is GMP_MSW_FIRST | GMP_NATIVE_ENDIAN.

Return Values

PHP gmp_export() function returns binary string or false on failure.

PHP Version

This function will work from PHP Version greater than 5.6.1.

Example 1

Working of gmp_export −

<?php
   $number = gmp_init(16708);
   echo "The binary value is : ".gmp_export($number);
?>

This will produce following result −

The binary value is : AD

Example 2

Using options parameter −

<?php
   $number = gmp_init(16708);
   echo "The binary value is : ".gmp_export($number, 2, GMP_MSW_FIRST );
?>

This will produce following result −

The binary value is : DA
php_function_reference.htm
Advertisements