3v4l.org

run code in 300+ PHP versions simultaneously
<?php function encode($string,$key) { $key = sha1($key); $strLen = strlen($string); $keyLen = strlen($key); for ($i = 0; $i < $strLen; $i++) { $ordStr = ord(substr($string,$i,1)); if ($j == $keyLen) { $j = 0; } $ordKey = ord(substr($key,$j,1)); $j++; $hash .= strrev(base_convert(dechex($ordStr + $ordKey),16,36)); } return $hash; } function decode($string,$key) { $key = sha1($key); $strLen = strlen($string); $keyLen = strlen($key); for ($i = 0; $i < $strLen; $i+=2) { $ordStr = hexdec(base_convert(strrev(substr($string,$i,2)),36,16)); if ($j == $keyLen) { $j = 0; } $ordKey = ord(substr($key,$j,1)); $j++; $hash .= chr($ordStr - $ordKey); } return $hash; } echo encode("i:1:1",3029); echo decode(encode("i:1:1"),3029); ?>
Output for git.master, git.master_jit, rfc.property-hooks
Warning: Undefined variable $j in /in/7LWKW on line 8 Warning: Undefined variable $j in /in/7LWKW on line 9 Deprecated: substr(): Passing null to parameter #2 ($offset) of type int is deprecated in /in/7LWKW on line 9 Warning: Undefined variable $j in /in/7LWKW on line 10 Warning: Undefined variable $hash in /in/7LWKW on line 11 p533q273t2 Fatal error: Uncaught ArgumentCountError: Too few arguments to function encode(), 1 passed in /in/7LWKW on line 30 and exactly 2 expected in /in/7LWKW:2 Stack trace: #0 /in/7LWKW(30): encode('i:1:1') #1 {main} thrown in /in/7LWKW on line 2
Process exited with code 255.

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
43.59 ms | 402 KiB | 8 Q