PHP crc32()Functions
Examples
Output the result of crc32():
Run Example »
Definition and Usage
The crc32() function calculates a 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 must use the %u format specifier of the printf() or sprintf() functions. If the %u format specifier is not used, the result may be displayed as an incorrect number or a negative number.
Syntax
| Parameter | Description |
|---|---|
| string | Required. Specifies the string to be calculated. |
Technical Details
| Return value: | Returns, as an integer,stringthe 32-bit cyclic redundancy check polynomial of the string. |
|---|---|
| PHP version: | 4.0.1+ |
Example 1
In this example, we will output the result of crc32() with and without using the "%u" format specifier (note that the results are the same):
Example
The above code will output:
Without %u: 461707669 With %u: 461707669
Example 2
In this example, we will output the result of crc32() with and without using the "%u" format specifier (note that the results are not the same):
Example
The above code will output:
Without %u: -1959132156 With %u: 2335835140
Other Extensions
PHP String Reference Manual