PHP crc32()函數(shù)
PHP crc32()函數(shù)是一種重要的字符串函數(shù),用于計算字符串的crc32(循環(huán)冗余校驗)多項式。愛掏網(wǎng) - it200.com它可以用于驗證數(shù)據(jù)完整性。愛掏網(wǎng) - it200.com
注意:如果你使用crc32()函數(shù),必須使用%u格式化符號來使用printf()或sprintf()函數(shù)。愛掏網(wǎng) - it200.com如果不使用,則返回錯誤或負值。愛掏網(wǎng) - it200.com
int crc32 ( string $str )
參數(shù) | 描述 | 必需/可選 |
---|---|---|
字符串 | 需要計算的字符串。愛掏網(wǎng) - it200.com | 必需 |
示例1
<?php
checksum = crc32("Hello how are you?.");
printf("%u\n",checksum);
?>
輸出:
2454994420
示例2
<?php
str ="Hello JavaTpoint";
echo "Your string value is : ".str."<br>";
str =crc32(str);
printf("%u\n", $str);
?>
輸出:
Your string value is : Hello JavaTpoint
1303530391
示例3
<?php
str = crc32("Hello JavaTpoint");
echo 'Without %u: '.str."<br>";
echo 'With %u: ';
printf("%u",$str);
?>
輸出:
Without %u: 1303530391
With %u: 1303530391
聲明:所有內(nèi)容來自互聯(lián)網(wǎng)搜索結(jié)果,不保證100%準確性,僅供參考。如若本站內(nèi)容侵犯了原著者的合法權(quán)益,可聯(lián)系我們進行處理。