Home >>PHP String Functions >PHP crc32() Function

PHP crc32() Function

PHP Crc32() Function

The PHP crc32() function is used to get the 32-bit cyclic redundancy checksum code of the given input string. To convert the given input string into a 32-bit cyclic redundancy checksum code this crc32() function uses the CRC32 algorithm.

Syntax :

crc32($string)

The $string is the given input string which will be passed to the function as a parameter.

We use the "%u" & printf to make sure that the output which we get is correct because sometimes the output could be in negative so it's better to use the crc32() function with "%u".

Let's see some examples of this crc32() function:

<html>
<body>
<?php
$str = crc32("PHPTPOINT");
echo $str;
?>  
</body>
</html>
Output:
1547364703

Example 2

<html>
<body>
<?php
$str = "PHP is a server side scripting language. that is used to develop Static websites or Dynamic websites or Web applications";
echo crc32($str);
?>  
</body>
</html>
Output:
3727077676

Example 3

<html>
<body>

<?php
$str = crc32("We love PHP !!!");

echo "without %u:".$str."<br>";
echo "with %u:";
printf ("%u",$str);
?> 

</body>
</html>
Output:
without %u:577534530
with %u:577534530

Popular Tutorials