$str = "11000101"; $len = CUtil::BinStrlen($str); echo "The length of the binary string is " . $len;
The length of the binary string is 8
$str = "101010101010"; $len = CUtil::BinStrlen($str); if($len % 2 == 0){ echo "The binary string is even"; } else { echo "The binary string is odd"; }
The binary string is evenIn this example, the BinStrlen function is used to determine the length of the binary string "101010101010" which is 12. Then, the code checks whether the length of the binary string is even or odd. Since the length is even, the output is "The binary string is even".