crc32() function in PHP


The crc32() function is used to calculate 32-bit CRC. You can use the function to validate data integrity.

Syntax

crc32(str)

Parameters

  • str  − The string

Return

The crc32() function returns the crc32 checksum of string as an integer.

Example

The following is an example −

 Live Demo

<?php
   $res = crc32("This is demo text!");
   printf("%u
", $res); ?>

Output

2903462745

Example

Let us see another example −

 Live Demo

<?php
   $s = crc32("Welcome!");
   echo 'First:'.$s."
";    printf("Second: %u
", $s); ?>

Output

First: 893564114 Second: 893564114

Updated on: 26-Dec-2019

66 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements