PHP - gmp_xor() 函式



定義和用法

gmp_xor() 函式計算給定數字的按位異或。

描述

gmp_xor() 計算給定兩個 GMP 數字的按位異或(XOR)。

語法

gmp_xor ( GMP $a , GMP $b ) : GMP

引數

序號 引數及描述
1

a

可以是 GMP 資源數字、gmp 物件或數字字串。

2

b

可以是 GMP 資源數字、gmp 物件或數字字串。

返回值

PHP gmp_xor() 函式返回 GMP 數字。

PHP 版本

此函式在 PHP 5.0.0 以上版本中可用。

示例 1

gmp_xor() 的工作原理 -

<?php
   $xor1 = gmp_xor("0xffeffcd", "16");
   $num1 =  gmp_strval($xor1, 2);
   echo "The result is :".$num1;
?>

這將產生以下結果 -

The result is :1111111111101111111111011101

示例 2

gmp_xor() 的工作原理 -

<?php
   $xor1 = gmp_xor("0xffeffcd", "16");
   $num1 =  gmp_strval($xor1, 8);
   echo "The result is :".$num1;
?>

這將產生以下結果 -

The result is :1777577735
php_function_reference.htm
廣告