crc32
Calculates the CRC32 checksum of a string.
Syntax
crc32(string $string): intParameters
| Parameter | Type | Description |
|---|---|---|
| $string | string | The input string. |
Return value
intAn integer checksum.
Examples
The number and its hexadecimal form:
<?php
echo crc32('hello'), "\n";
echo hash('crc32b', 'hello');Output:
907060870
3610a686Notes
The checksum is fast but short: different strings collide often, and it is not suitable for protecting data. On 32-bit systems the result may be negative — the hash('crc32b', …) form does not depend on that.
See also
In the tutorial
- Strings — Working with strings in PHP — quotes, concatenation, length, searching, replacing and multibyte functions.