3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php /* string encryptDecrypt(string toEncrypt) { char key[3] = {'K', 'C', 'Q'}; //Any chars will work string output = toEncrypt; for (int i = 0; i < toEncrypt.size(); i++) output[i] = toEncrypt[i] ^ key[i % (sizeof(key) / sizeof(char))]; return output; } function XoR($string) { $Key = ('K', 'C', 'Q'); $Text = "kylewbanks.com"; for($i=0;$i<strlen($Text);) { } } */ function xor_this($text) { $key = pack('K', 'C', 'Q'); $i = 0; $encrypted = ''; foreach (str_split($text) as $char) { $encrypted .= chr(ord($char) ^ ord($key{$i++ % strlen($key)})); } return $encrypted; } $text = 'kylewbanks.com'; print xor_this($text); ?>
based on f5K93
Output for 7.0.0 - 7.2.0
Warning: pack(): Type K: unknown format code in /in/anAUn on line 26 Fatal error: Uncaught DivisionByZeroError: Modulo by zero in /in/anAUn:30 Stack trace: #0 /in/anAUn(36): xor_this('kylewbanks.com') #1 {main} thrown in /in/anAUn on line 30
Process exited with code 255.
Output for 5.3.21 - 5.6.28
Warning: pack(): Type K: unknown format code in /in/anAUn on line 26 Warning: Division by zero in /in/anAUn on line 30 Warning: Division by zero in /in/anAUn on line 30 Warning: Division by zero in /in/anAUn on line 30 Warning: Division by zero in /in/anAUn on line 30 Warning: Division by zero in /in/anAUn on line 30 Warning: Division by zero in /in/anAUn on line 30 Warning: Division by zero in /in/anAUn on line 30 Warning: Division by zero in /in/anAUn on line 30 Warning: Division by zero in /in/anAUn on line 30 Warning: Division by zero in /in/anAUn on line 30 Warning: Division by zero in /in/anAUn on line 30 Warning: Division by zero in /in/anAUn on line 30 Warning: Division by zero in /in/anAUn on line 30 Warning: Division by zero in /in/anAUn on line 30 kylewbanks.com