Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

php

What is the gmp_export() function in PHP?

Abhilash

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

Overview

The gmp_export() function in PHP converts the number to a binary string.

Syntax

gmp_export(GMP|int|string $num, int $word_size = 1, int $flags = GMP_MSW_FIRST | GMP_NATIVE_ENDIAN): string

Parameters

  • num: This is a GMP object, integer, or a string value to convert to a binary string.
  • word_size: This parameter indicates the number of bytes in a chunk of binary data. The default value is 1. This is dependent on the flags parameter.
  • flags: The default value is GMP_MSW_FIRST | GMP_NATIVE_ENDIAN.

Return value

The method returns a binary string.

Code

<?php
$bin = gmp_export(12343);
echo "gmp_export(12343) - ".$bin;
?>
Implementation of gmp_export()

Explanation

  • Line 2: We construct a gmp number using the gmp_init() method.
  • Line 3: We print the binary string.

RELATED TAGS

php

CONTRIBUTOR

Abhilash
Copyright ©2022 Educative, Inc. All rights reserved

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

Keep Exploring