3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php function encode($to_encode){ $i=0; $len=strlen($to_encode); $ret=''; for($i=0;$i<$len;++$i){ $ret.=str_pad(ord($to_encode[$i]),4,"0",STR_PAD_LEFT);//4 should be enough for UTF-8, right? } return $ret; } function decode($numberstr){ $numberstr=(string)$numberstr; $ret=''; $i=0; $ii=0; $len=strlen($numberstr); $shit=''; $len2=null; for($i=0;$i<$len;$i+=4){ $shit=ltrim(substr($numberstr,$i,4),'0'); $ret.=chr($shit[$i]); } return $ret; } $str="the quick brown fox jumps over the lazy dog こどものじかん"; var_dump($str,encode($str),decode(encode($str)));
Output for 5.2.10 - 5.6.28, 7.0.0 - 7.1.0
Notice: Uninitialized string offset: 4 in /in/vPPk1 on line 22 Notice: Uninitialized string offset: 8 in /in/vPPk1 on line 22 Notice: Uninitialized string offset: 12 in /in/vPPk1 on line 22 Notice: Uninitialized string offset: 16 in /in/vPPk1 on line 22 Notice: Uninitialized string offset: 20 in /in/vPPk1 on line 22 Notice: Uninitialized string offset: 24 in /in/vPPk1 on line 22 Notice: Uninitialized string offset: 28 in /in/vPPk1 on line 22 Notice: Uninitialized string offset: 32 in /in/vPPk1 on line 22 Notice: Uninitialized string offset: 36 in /in/vPPk1 on line 22 Notice: Uninitialized string offset: 40 in /in/vPPk1 on line 22 Notice: Uninitialized string offset: 44 in /in/vPPk1 on line 22 Notice: Uninitialized string offset: 48 in /in/vPPk1 on line 22 Notice: Uninitialized string offset: 52 in /in/vPPk1 on line 22 Notice: Uninitialized string offset: 56 in /in/vPPk1 on line 22 Notice: Uninitialized string offset: 60 in /in/vPPk1 on line 22 Notice: Uninitialized string offset: 64 in /in/vPPk1 on line 22 Notice: Uninitialized string offset: 68 in /in/vPPk1 on line 22 Notice: Uninitialized string offset: 72 in /in/vPPk1 on line 22 Notice: Uninitialized string offset: 76 in /in/vPPk1 on line 22 Notice: Uninitialized string offset: 80 in /in/vPPk1 on line 22 Notice: Uninitialized string offset: 84 in /in/vPPk1 on line 22 Notice: Uninitialized string offset: 88 in /in/vPPk1 on line 22 Notice: Uninitialized string offset: 92 in /in/vPPk1 on line 22 Notice: Uninitialized string offset: 96 in /in/vPPk1 on line 22 Notice: Uninitialized string offset: 100 in /in/vPPk1 on line 22 Notice: Uninitialized string offset: 104 in /in/vPPk1 on line 22 Notice: Uninitialized string offset: 108 in /in/vPPk1 on line 22 Notice: Uninitialized string offset: 112 in /in/vPPk1 on line 22 Notice: Uninitialized string offset: 116 in /in/vPPk1 on line 22 Notice: Uninitialized string offset: 120 in /in/vPPk1 on line 22 Notice: Uninitialized string offset: 124 in /in/vPPk1 on line 22 Notice: Uninitialized string offset: 128 in /in/vPPk1 on line 22 Notice: Uninitialized string offset: 132 in /in/vPPk1 on line 22 Notice: Uninitialized string offset: 136 in /in/vPPk1 on line 22 Notice: Uninitialized string offset: 140 in /in/vPPk1 on line 22 Notice: Uninitialized string offset: 144 in /in/vPPk1 on line 22 Notice: Uninitialized string offset: 148 in /in/vPPk1 on line 22 Notice: Uninitialized string offset: 152 in /in/vPPk1 on line 22 Notice: Uninitialized string offset: 156 in /in/vPPk1 on line 22 Notice: Uninitialized string offset: 160 in /in/vPPk1 on line 22 Notice: Uninitialized string offset: 164 in /in/vPPk1 on line 22 Notice: Uninitialized string offset: 168 in /in/vPPk1 on line 22 Notice: Uninitialized string offset: 172 in /in/vPPk1 on line 22 Notice: Uninitialized string offset: 176 in /in/vPPk1 on line 22 Notice: Uninitialized string offset: 180 in /in/vPPk1 on line 22 Notice: Uninitialized string offset: 184 in /in/vPPk1 on line 22 Notice: Uninitialized string offset: 188 in /in/vPPk1 on line 22 Notice: Uninitialized string offset: 192 in /in/vPPk1 on line 22 Notice: Uninitialized string offset: 196 in /in/vPPk1 on line 22 Notice: Uninitialized string offset: 200 in /in/vPPk1 on line 22 Notice: Uninitialized string offset: 204 in /in/vPPk1 on line 22 Notice: Uninitialized string offset: 208 in /in/vPPk1 on line 22 Notice: Uninitialized string offset: 212 in /in/vPPk1 on line 22 Notice: Uninitialized string offset: 216 in /in/vPPk1 on line 22 Notice: Uninitialized string offset: 220 in /in/vPPk1 on line 22 Notice: Uninitialized string offset: 224 in /in/vPPk1 on line 22 Notice: Uninitialized string offset: 228 in /in/vPPk1 on line 22 Notice: Uninitialized string offset: 232 in /in/vPPk1 on line 22 Notice: Uninitialized string offset: 236 in /in/vPPk1 on line 22 Notice: Uninitialized string offset: 240 in /in/vPPk1 on line 22 Notice: Uninitialized string offset: 244 in /in/vPPk1 on line 22 Notice: Uninitialized string offset: 248 in /in/vPPk1 on line 22 Notice: Uninitialized string offset: 252 in /in/vPPk1 on line 22 Notice: Uninitialized string offset: 256 in /in/vPPk1 on line 22 string(65) "the quick brown fox jumps over the lazy dog こどものじかん" string(260) "01160104010100320113011701050099010700320098011401110119011000320102011101200032010601170109011201150032011101180101011400320116010401010032010800970122012100320100011101030032022701290147022701290169022701300130022701290174022701290152022701290139022701300147" string(65) ""
Output for hhvm-3.10.0 - 3.12.0
string(65) "the quick brown fox jumps over the lazy dog こどものじかん" string(260) "01160104010100320113011701050099010700320098011401110119011000320102011101200032010601170109011201150032011101180101011400320116010401010032010800970122012100320100011101030032022701290147022701290169022701300130022701290174022701290152022701290139022701300147" string(65) ""
Output for 4.3.0 - 5.2.9
Notice: Uninitialized string offset: 4 in /in/vPPk1 on line 22 Notice: Uninitialized string offset: 8 in /in/vPPk1 on line 22 Notice: Uninitialized string offset: 12 in /in/vPPk1 on line 22 Notice: Uninitialized string offset: 16 in /in/vPPk1 on line 22 Notice: Uninitialized string offset: 20 in /in/vPPk1 on line 22 Notice: Uninitialized string offset: 24 in /in/vPPk1 on line 22 Notice: Uninitialized string offset: 28 in /in/vPPk1 on line 22 Notice: Uninitialized string offset: 32 in /in/vPPk1 on line 22 Notice: Uninitialized string offset: 36 in /in/vPPk1 on line 22 Notice: Uninitialized string offset: 40 in /in/vPPk1 on line 22 Notice: Uninitialized string offset: 44 in /in/vPPk1 on line 22 Notice: Uninitialized string offset: 48 in /in/vPPk1 on line 22 Notice: Uninitialized string offset: 52 in /in/vPPk1 on line 22 Notice: Uninitialized string offset: 56 in /in/vPPk1 on line 22 Notice: Uninitialized string offset: 60 in /in/vPPk1 on line 22 Notice: Uninitialized string offset: 64 in /in/vPPk1 on line 22 Notice: Uninitialized string offset: 68 in /in/vPPk1 on line 22 Notice: Uninitialized string offset: 72 in /in/vPPk1 on line 22 Notice: Uninitialized string offset: 76 in /in/vPPk1 on line 22 Notice: Uninitialized string offset: 80 in /in/vPPk1 on line 22 Notice: Uninitialized string offset: 84 in /in/vPPk1 on line 22 Notice: Uninitialized string offset: 88 in /in/vPPk1 on line 22 Notice: Uninitialized string offset: 92 in /in/vPPk1 on line 22 Notice: Uninitialized string offset: 96 in /in/vPPk1 on line 22 Notice: Uninitialized string offset: 100 in /in/vPPk1 on line 22 Notice: Uninitialized string offset: 104 in /in/vPPk1 on line 22 Notice: Uninitialized string offset: 108 in /in/vPPk1 on line 22 Notice: Uninitialized string offset: 112 in /in/vPPk1 on line 22 Notice: Uninitialized string offset: 116 in /in/vPPk1 on line 22 Notice: Uninitialized string offset: 120 in /in/vPPk1 on line 22 Notice: Uninitialized string offset: 124 in /in/vPPk1 on line 22 Notice: Uninitialized string offset: 128 in /in/vPPk1 on line 22 Notice: Uninitialized string offset: 132 in /in/vPPk1 on line 22 Notice: Uninitialized string offset: 136 in /in/vPPk1 on line 22 Notice: Uninitialized string offset: 140 in /in/vPPk1 on line 22 Notice: Uninitialized string offset: 144 in /in/vPPk1 on line 22 Notice: Uninitialized string offset: 148 in /in/vPPk1 on line 22 Notice: Uninitialized string offset: 152 in /in/vPPk1 on line 22 Notice: Uninitialized string offset: 156 in /in/vPPk1 on line 22 Notice: Uninitialized string offset: 160 in /in/vPPk1 on line 22 Notice: Uninitialized string offset: 164 in /in/vPPk1 on line 22 Notice: Uninitialized string offset: 168 in /in/vPPk1 on line 22 Notice: Uninitialized string offset: 172 in /in/vPPk1 on line 22 Notice: Uninitialized string offset: 176 in /in/vPPk1 on line 22 Notice: Uninitialized string offset: 180 in /in/vPPk1 on line 22 Notice: Uninitialized string offset: 184 in /in/vPPk1 on line 22 Notice: Uninitialized string offset: 188 in /in/vPPk1 on line 22 Notice: Uninitialized string offset: 192 in /in/vPPk1 on line 22 Notice: Uninitialized string offset: 196 in /in/vPPk1 on line 22 Notice: Uninitialized string offset: 200 in /in/vPPk1 on line 22 Notice: Uninitialized string offset: 204 in /in/vPPk1 on line 22 Notice: Uninitialized string offset: 208 in /in/vPPk1 on line 22 Notice: Uninitialized string offset: 212 in /in/vPPk1 on line 22 Notice: Uninitialized string offset: 216 in /in/vPPk1 on line 22 Notice: Uninitialized string offset: 220 in /in/vPPk1 on line 22 Notice: Uninitialized string offset: 224 in /in/vPPk1 on line 22 Notice: Uninitialized string offset: 228 in /in/vPPk1 on line 22 Notice: Uninitialized string offset: 232 in /in/vPPk1 on line 22 Notice: Uninitialized string offset: 236 in /in/vPPk1 on line 22 Notice: Uninitialized string offset: 240 in /in/vPPk1 on line 22 Notice: Uninitialized string offset: 244 in /in/vPPk1 on line 22 Notice: Uninitialized string offset: 248 in /in/vPPk1 on line 22 Notice: Uninitialized string offset: 252 in /in/vPPk1 on line 22 Notice: Uninitialized string offset: 256 in /in/vPPk1 on line 22 string(65) "the quick brown fox jumps over the lazy dog こどものじかん" string(260) "01160104010100320113011701050099010700320098011401110119011000320102011101200032010601170109011201150032011101180101011400320116010401010032010800970122012100320100011101030032022701290147022701290169022701300130022701290174022701290152022701290139022701300147" string(65) ""