PHP crc32() Function

PHP crc32() function is important string function, which is used to calculate the crc32( cyclic redundancy checksum ) polynomial of a string. It can be used to validate data integrity.

Syntax:


int crc32 ( string $str )  
  
Parameter Description Required/Optional
string The string to be calculated. Required

Example 1


<?php 
$checksum = crc32("Hello how are you?.");  
printf("%un", $checksum);  
?>

Output

2454994420

Example 2


<?php 
$str ="Hello Shorat Innovation";  
echo "Your string value is : ".$str."<br>";   
$str =crc32($str);  
printf("%un", $str);   
?>
        

Output

Your string value is : Hello Shorat Innovation Your crc32 value is : 3283648563

Example 3


<?php  
$str = crc32("Hello Shorat Innovation");  
echo 'Without %u: '.$str./"<br>";  
echo 'With %u: ';  
printf("%u",$str);   
>?
    

Output

Without %u:3283648563 With %u : Same: `