3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $str = "Ваc зовут O\'reilly? \\/\\/\\"; function utf8_to_cp1251($s) { for ($c=0;$c<strlen($s);$c++) { $i=ord($s[$c]); if ($i<=127) $out.=$s[$c]; if ($byte2){ $new_c2=($c1&3)*64+($i&63); $new_c1=($c1>>2)&5; $new_i=$new_c1*256+$new_c2; if ($new_i==1025){ $out_i=168; } else { if ($new_i==1105){ $out_i=184; } else { $out_i=$new_i-848; } } $out.=chr($out_i); $byte2=false; } if (($i>>5)==6) { $c1=$i; $byte2=true; } } return $out; } echo utf8_to_cp1251($str);
Output for 5.0.4 - 5.6.28, 7.0.0 - 7.1.0
Notice: Undefined variable: byte2 in /in/L6XGC on line 10 Notice: Undefined variable: out in /in/L6XGC on line 23 ��c ����� O\'reilly? \/\/\
Output for hhvm-3.10.0 - 3.12.0
Notice: Undefined variable: byte2 in /in/L6XGC on line 10 ��c ����� O\'reilly? \/\/\
Output for 4.3.0 - 5.0.3
Notice: Undefined variable: byte2 in /in/L6XGC on line 10 Notice: Undefined variable: out in /in/L6XGC on line 23 ��c ����� O\'reilly? \/\/\