3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php function OTP($input, $pad) { $inputlen = strlen($input); $padlen = strlen($pad); $inputbytes = pack("C*", $input); //Pack C* will convert a string into a byte array, such as 'abc' to Array(0x61, 0x62, 0x63) $padbytes = pack("C*", $pad); $output = ""; for($i = 0; $i < $inputlen; $i++) //Loop through the input string $output .= chr($inputbytes[$i] ^ $padbytes[$i % $padlen]); return $output; } echo OTP("This is a long input that is not subject to the size of the pad", "ABC");
based on iZHLG
Output for 5.2.10 - 7.2.0
Notice: Uninitialized string offset: 1 in /in/cTlS8 on line 11 Notice: Uninitialized string offset: 1 in /in/cTlS8 on line 11 Notice: Uninitialized string offset: 2 in /in/cTlS8 on line 11 Notice: Uninitialized string offset: 2 in /in/cTlS8 on line 11 Notice: Uninitialized string offset: 3 in /in/cTlS8 on line 11 Notice: Uninitialized string offset: 4 in /in/cTlS8 on line 11 Notice: Uninitialized string offset: 1 in /in/cTlS8 on line 11 Notice: Uninitialized string offset: 5 in /in/cTlS8 on line 11 Notice: Uninitialized string offset: 2 in /in/cTlS8 on line 11 Notice: Uninitialized string offset: 6 in /in/cTlS8 on line 11 Notice: Uninitialized string offset: 7 in /in/cTlS8 on line 11 Notice: Uninitialized string offset: 1 in /in/cTlS8 on line 11 Notice: Uninitialized string offset: 8 in /in/cTlS8 on line 11 Notice: Uninitialized string offset: 2 in /in/cTlS8 on line 11 Notice: Uninitialized string offset: 9 in /in/cTlS8 on line 11 Notice: Uninitialized string offset: 10 in /in/cTlS8 on line 11 Notice: Uninitialized string offset: 1 in /in/cTlS8 on line 11 Notice: Uninitialized string offset: 11 in /in/cTlS8 on line 11 Notice: Uninitialized string offset: 2 in /in/cTlS8 on line 11 Notice: Uninitialized string offset: 12 in /in/cTlS8 on line 11 Notice: Uninitialized string offset: 13 in /in/cTlS8 on line 11 Notice: Uninitialized string offset: 1 in /in/cTlS8 on line 11 Notice: Uninitialized string offset: 14 in /in/cTlS8 on line 11 Notice: Uninitialized string offset: 2 in /in/cTlS8 on line 11 Notice: Uninitialized string offset: 15 in /in/cTlS8 on line 11 Notice: Uninitialized string offset: 16 in /in/cTlS8 on line 11 Notice: Uninitialized string offset: 1 in /in/cTlS8 on line 11 Notice: Uninitialized string offset: 17 in /in/cTlS8 on line 11 Notice: Uninitialized string offset: 2 in /in/cTlS8 on line 11 Notice: Uninitialized string offset: 18 in /in/cTlS8 on line 11 Notice: Uninitialized string offset: 19 in /in/cTlS8 on line 11 Notice: Uninitialized string offset: 1 in /in/cTlS8 on line 11 Notice: Uninitialized string offset: 20 in /in/cTlS8 on line 11 Notice: Uninitialized string offset: 2 in /in/cTlS8 on line 11 Notice: Uninitialized string offset: 21 in /in/cTlS8 on line 11 Notice: Uninitialized string offset: 22 in /in/cTlS8 on line 11 Notice: Uninitialized string offset: 1 in /in/cTlS8 on line 11 Notice: Uninitialized string offset: 23 in /in/cTlS8 on line 11 Notice: Uninitialized string offset: 2 in /in/cTlS8 on line 11 Notice: Uninitialized string offset: 24 in /in/cTlS8 on line 11 Notice: Uninitialized string offset: 25 in /in/cTlS8 on line 11 Notice: Uninitialized string offset: 1 in /in/cTlS8 on line 11 Notice: Uninitialized string offset: 26 in /in/cTlS8 on line 11 Notice: Uninitialized string offset: 2 in /in/cTlS8 on line 11 Notice: Uninitialized string offset: 27 in /in/cTlS8 on line 11 Notice: Uninitialized string offset: 28 in /in/cTlS8 on line 11 Notice: Uninitialized string offset: 1 in /in/cTlS8 on line 11 Notice: Uninitialized string offset: 29 in /in/cTlS8 on line 11 Notice: Uninitialized string offset: 2 in /in/cTlS8 on line 11 Notice: Uninitialized string offset: 30 in /in/cTlS8 on line 11 Notice: Uninitialized string offset: 31 in /in/cTlS8 on line 11 Notice: Uninitialized string offset: 1 in /in/cTlS8 on line 11 Notice: Uninitialized string offset: 32 in /in/cTlS8 on line 11 Notice: Uninitialized string offset: 2 in /in/cTlS8 on line 11 Notice: Uninitialized string offset: 33 in /in/cTlS8 on line 11 Notice: Uninitialized string offset: 34 in /in/cTlS8 on line 11 Notice: Uninitialized string offset: 1 in /in/cTlS8 on line 11 Notice: Uninitialized string offset: 35 in /in/cTlS8 on line 11 Notice: Uninitialized string offset: 2 in /in/cTlS8 on line 11 Notice: Uninitialized string offset: 36 in /in/cTlS8 on line 11 Notice: Uninitialized string offset: 37 in /in/cTlS8 on line 11 Notice: Uninitialized string offset: 1 in /in/cTlS8 on line 11 Notice: Uninitialized string offset: 38 in /in/cTlS8 on line 11 Notice: Uninitialized string offset: 2 in /in/cTlS8 on line 11 Notice: Uninitialized string offset: 39 in /in/cTlS8 on line 11 Notice: Uninitialized string offset: 40 in /in/cTlS8 on line 11 Notice: Uninitialized string offset: 1 in /in/cTlS8 on line 11 Notice: Uninitialized string offset: 41 in /in/cTlS8 on line 11 Notice: Uninitialized string offset: 2 in /in/cTlS8 on line 11 Notice: Uninitialized string offset: 42 in /in/cTlS8 on line 11 Notice: Uninitialized string offset: 43 in /in/cTlS8 on line 11 Notice: Uninitialized string offset: 1 in /in/cTlS8 on line 11 Notice: Uninitialized string offset: 44 in /in/cTlS8 on line 11 Notice: Uninitialized string offset: 2 in /in/cTlS8 on line 11 Notice: Uninitialized string offset: 45 in /in/cTlS8 on line 11 Notice: Uninitialized string offset: 46 in /in/cTlS8 on line 11 Notice: Uninitialized string offset: 1 in /in/cTlS8 on line 11 Notice: Uninitialized string offset: 47 in /in/cTlS8 on line 11 Notice: Uninitialized string offset: 2 in /in/cTlS8 on line 11 Notice: Uninitialized string offset: 48 in /in/cTlS8 on line 11 Notice: Uninitialized string offset: 49 in /in/cTlS8 on line 11 Notice: Uninitialized string offset: 1 in /in/cTlS8 on line 11 Notice: Uninitialized string offset: 50 in /in/cTlS8 on line 11 Notice: Uninitialized string offset: 2 in /in/cTlS8 on line 11 Notice: Uninitialized string offset: 51 in /in/cTlS8 on line 11 Notice: Uninitialized string offset: 52 in /in/cTlS8 on line 11 Notice: Uninitialized string offset: 1 in /in/cTlS8 on line 11 Notice: Uninitialized string offset: 53 in /in/cTlS8 on line 11 Notice: Uninitialized string offset: 2 in /in/cTlS8 on line 11 Notice: Uninitialized string offset: 54 in /in/cTlS8 on line 11 Notice: Uninitialized string offset: 55 in /in/cTlS8 on line 11 Notice: Uninitialized string offset: 1 in /in/cTlS8 on line 11 Notice: Uninitialized string offset: 56 in /in/cTlS8 on line 11 Notice: Uninitialized string offset: 2 in /in/cTlS8 on line 11 Notice: Uninitialized string offset: 57 in /in/cTlS8 on line 11 Notice: Uninitialized string offset: 58 in /in/cTlS8 on line 11 Notice: Uninitialized string offset: 1 in /in/cTlS8 on line 11 Notice: Uninitialized string offset: 59 in /in/cTlS8 on line 11 Notice: Uninitialized string offset: 2 in /in/cTlS8 on line 11 Notice: Uninitialized string offset: 60 in /in/cTlS8 on line 11 Notice: Uninitialized string offset: 61 in /in/cTlS8 on line 11 Notice: Uninitialized string offset: 1 in /in/cTlS8 on line 11 Notice: Uninitialized string offset: 62 in /in/cTlS8 on line 11 Notice: Uninitialized string offset: 2 in /in/cTlS8 on line 11
Output for 4.3.0 - 5.2.9
Notice: Uninitialized string offset: 1 in /in/cTlS8 on line 11 Notice: Uninitialized string offset: 1 in /in/cTlS8 on line 11 Notice: Uninitialized string offset: 2 in /in/cTlS8 on line 11 Notice: Uninitialized string offset: 2 in /in/cTlS8 on line 11 Notice: Uninitialized string offset: 3 in /in/cTlS8 on line 11 Notice: Uninitialized string offset: 1 in /in/cTlS8 on line 11 Notice: Uninitialized string offset: 4 in /in/cTlS8 on line 11 Notice: Uninitialized string offset: 2 in /in/cTlS8 on line 11 Notice: Uninitialized string offset: 5 in /in/cTlS8 on line 11 Notice: Uninitialized string offset: 6 in /in/cTlS8 on line 11 Notice: Uninitialized string offset: 1 in /in/cTlS8 on line 11 Notice: Uninitialized string offset: 7 in /in/cTlS8 on line 11 Notice: Uninitialized string offset: 2 in /in/cTlS8 on line 11 Notice: Uninitialized string offset: 8 in /in/cTlS8 on line 11 Notice: Uninitialized string offset: 9 in /in/cTlS8 on line 11 Notice: Uninitialized string offset: 1 in /in/cTlS8 on line 11 Notice: Uninitialized string offset: 10 in /in/cTlS8 on line 11 Notice: Uninitialized string offset: 2 in /in/cTlS8 on line 11 Notice: Uninitialized string offset: 11 in /in/cTlS8 on line 11 Notice: Uninitialized string offset: 12 in /in/cTlS8 on line 11 Notice: Uninitialized string offset: 1 in /in/cTlS8 on line 11 Notice: Uninitialized string offset: 13 in /in/cTlS8 on line 11 Notice: Uninitialized string offset: 2 in /in/cTlS8 on line 11 Notice: Uninitialized string offset: 14 in /in/cTlS8 on line 11 Notice: Uninitialized string offset: 15 in /in/cTlS8 on line 11 Notice: Uninitialized string offset: 1 in /in/cTlS8 on line 11 Notice: Uninitialized string offset: 16 in /in/cTlS8 on line 11 Notice: Uninitialized string offset: 2 in /in/cTlS8 on line 11 Notice: Uninitialized string offset: 17 in /in/cTlS8 on line 11 Notice: Uninitialized string offset: 18 in /in/cTlS8 on line 11 Notice: Uninitialized string offset: 1 in /in/cTlS8 on line 11 Notice: Uninitialized string offset: 19 in /in/cTlS8 on line 11 Notice: Uninitialized string offset: 2 in /in/cTlS8 on line 11 Notice: Uninitialized string offset: 20 in /in/cTlS8 on line 11 Notice: Uninitialized string offset: 21 in /in/cTlS8 on line 11 Notice: Uninitialized string offset: 1 in /in/cTlS8 on line 11 Notice: Uninitialized string offset: 22 in /in/cTlS8 on line 11 Notice: Uninitialized string offset: 2 in /in/cTlS8 on line 11 Notice: Uninitialized string offset: 23 in /in/cTlS8 on line 11 Notice: Uninitialized string offset: 24 in /in/cTlS8 on line 11 Notice: Uninitialized string offset: 1 in /in/cTlS8 on line 11 Notice: Uninitialized string offset: 25 in /in/cTlS8 on line 11 Notice: Uninitialized string offset: 2 in /in/cTlS8 on line 11 Notice: Uninitialized string offset: 26 in /in/cTlS8 on line 11 Notice: Uninitialized string offset: 27 in /in/cTlS8 on line 11 Notice: Uninitialized string offset: 1 in /in/cTlS8 on line 11 Notice: Uninitialized string offset: 28 in /in/cTlS8 on line 11 Notice: Uninitialized string offset: 2 in /in/cTlS8 on line 11 Notice: Uninitialized string offset: 29 in /in/cTlS8 on line 11 Notice: Uninitialized string offset: 30 in /in/cTlS8 on line 11 Notice: Uninitialized string offset: 1 in /in/cTlS8 on line 11 Notice: Uninitialized string offset: 31 in /in/cTlS8 on line 11 Notice: Uninitialized string offset: 2 in /in/cTlS8 on line 11 Notice: Uninitialized string offset: 32 in /in/cTlS8 on line 11 Notice: Uninitialized string offset: 33 in /in/cTlS8 on line 11 Notice: Uninitialized string offset: 1 in /in/cTlS8 on line 11 Notice: Uninitialized string offset: 34 in /in/cTlS8 on line 11 Notice: Uninitialized string offset: 2 in /in/cTlS8 on line 11 Notice: Uninitialized string offset: 35 in /in/cTlS8 on line 11 Notice: Uninitialized string offset: 36 in /in/cTlS8 on line 11 Notice: Uninitialized string offset: 1 in /in/cTlS8 on line 11 Notice: Uninitialized string offset: 37 in /in/cTlS8 on line 11 Notice: Uninitialized string offset: 2 in /in/cTlS8 on line 11 Notice: Uninitialized string offset: 38 in /in/cTlS8 on line 11 Notice: Uninitialized string offset: 39 in /in/cTlS8 on line 11 Notice: Uninitialized string offset: 1 in /in/cTlS8 on line 11 Notice: Uninitialized string offset: 40 in /in/cTlS8 on line 11 Notice: Uninitialized string offset: 2 in /in/cTlS8 on line 11 Notice: Uninitialized string offset: 41 in /in/cTlS8 on line 11 Notice: Uninitialized string offset: 42 in /in/cTlS8 on line 11 Notice: Uninitialized string offset: 1 in /in/cTlS8 on line 11 Notice: Uninitialized string offset: 43 in /in/cTlS8 on line 11 Notice: Uninitialized string offset: 2 in /in/cTlS8 on line 11 Notice: Uninitialized string offset: 44 in /in/cTlS8 on line 11 Notice: Uninitialized string offset: 45 in /in/cTlS8 on line 11 Notice: Uninitialized string offset: 1 in /in/cTlS8 on line 11 Notice: Uninitialized string offset: 46 in /in/cTlS8 on line 11 Notice: Uninitialized string offset: 2 in /in/cTlS8 on line 11 Notice: Uninitialized string offset: 47 in /in/cTlS8 on line 11 Notice: Uninitialized string offset: 48 in /in/cTlS8 on line 11 Notice: Uninitialized string offset: 1 in /in/cTlS8 on line 11 Notice: Uninitialized string offset: 49 in /in/cTlS8 on line 11 Notice: Uninitialized string offset: 2 in /in/cTlS8 on line 11 Notice: Uninitialized string offset: 50 in /in/cTlS8 on line 11 Notice: Uninitialized string offset: 51 in /in/cTlS8 on line 11 Notice: Uninitialized string offset: 1 in /in/cTlS8 on line 11 Notice: Uninitialized string offset: 52 in /in/cTlS8 on line 11 Notice: Uninitialized string offset: 2 in /in/cTlS8 on line 11 Notice: Uninitialized string offset: 53 in /in/cTlS8 on line 11 Notice: Uninitialized string offset: 54 in /in/cTlS8 on line 11 Notice: Uninitialized string offset: 1 in /in/cTlS8 on line 11 Notice: Uninitialized string offset: 55 in /in/cTlS8 on line 11 Notice: Uninitialized string offset: 2 in /in/cTlS8 on line 11 Notice: Uninitialized string offset: 56 in /in/cTlS8 on line 11 Notice: Uninitialized string offset: 57 in /in/cTlS8 on line 11 Notice: Uninitialized string offset: 1 in /in/cTlS8 on line 11 Notice: Uninitialized string offset: 58 in /in/cTlS8 on line 11 Notice: Uninitialized string offset: 2 in /in/cTlS8 on line 11 Notice: Uninitialized string offset: 59 in /in/cTlS8 on line 11 Notice: Uninitialized string offset: 60 in /in/cTlS8 on line 11 Notice: Uninitialized string offset: 1 in /in/cTlS8 on line 11 Notice: Uninitialized string offset: 61 in /in/cTlS8 on line 11 Notice: Uninitialized string offset: 2 in /in/cTlS8 on line 11 Notice: Uninitialized string offset: 62 in /in/cTlS8 on line 11