PHP crc32() ফাংশন

উদাহরণ

ক্রসোরি ফলাফল প্রদর্শন:

<?php
$str = crc32("Shanghai");
printf("睵n",$str);
?>

Run Example

Definition and Usage

The crc32() function calculates the 32-bit CRC (Cyclic Redundancy Check) of a string.

This function can be used to verify data integrity.

Tip:To ensure that you get the correct string representation from the crc32() function, you need to use the ꊻmat specifier of the printf() or sprintf() function. If the ꊻmat specifier is not used, the result may be displayed as an incorrect number or a negative number.

Syntax

crc32(string)
Parameter Description
string Required. Specifies the string to be calculated.

Technical Details

Return Value: Returns the 32-bit CRC (Cyclic Redundancy Check) polynomial of a string as an integer value.
PHP Version: 4.0.1+

Example 1

In this example, we will output the result of crc32() with and without using the "眻 format specifier (note that the results are the same):

<?php
$str = crc32("Hello world!");
echo 'Without ៷$str."<br>";
echo 'With ᠄
printf("眻,$str);
?>

The output of the above code:

Without ᥆1707669
With ᥆1707669

Example 2

In this example, we will output the result of crc32() with and without using the "眻 format specifier (note that the results are different):

<?php
$str = crc32("Hello world.");
echo 'Without ៷$str."<br>";
echo 'With ᠄
printf("眻,$str);
?>

The output of the above code:

Without ᡡ959132156
With ᤣ35835140