Tell me, please, why the script does not display the result of the conversion from the decimal system to the binary. What is wrong here?
<?php $bin = '101'; function myBin2Dec($bin) { $n = strlen((string)$bin); for ($dec = 0, $i = 0; $i < n; $i++) { $dec = 2 * $dec + (int)$bin{$i}; } echo "=======\n<br>bin = ".$bin."; base = 10\n</br>=======</br>"; return $dec; } $result = myBin2Dec($bin); echo "result = ".$result."\n</br>"; ?>