crc32() String Function PHP 8.4 With Example

The `crc32()` string function in PHP 8.4 calculates the CRC32 (Cyclic Redundancy Check) polynomial of a string. It returns an integer hash value that can be used for quick integrity checks.

Syntax

crc32(string $str): int

$str: The input string for which the CRC32 checksum is calculated.
Returns: The 32-bit integer checksum.

Example:

<?php
$str = "Hello, World!";
$crc = crc32($str);
echo "CRC32 Checksum: " . sprintf("%u", $crc); // %u ensures an unsigned integer output
?>

Output

CRC32 Checksum: 3957769958