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),3040); ?>
Output for git.master, git.master_jit, rfc.property-hooks
Warning: Undefined variable $j in /in/DWhHo on line 8 Warning: Undefined variable $j in /in/DWhHo on line 9 Deprecated: substr(): Passing null to parameter #2 ($offset) of type int is deprecated in /in/DWhHo on line 9 Warning: Undefined variable $j in /in/DWhHo on line 10 Warning: Undefined variable $hash in /in/DWhHo on line 11 p533q273t2 Warning: Undefined variable $j in /in/DWhHo on line 8 Warning: Undefined variable $j in /in/DWhHo on line 9 Deprecated: substr(): Passing null to parameter #2 ($offset) of type int is deprecated in /in/DWhHo on line 9 Warning: Undefined variable $j in /in/DWhHo on line 10 Warning: Undefined variable $hash in /in/DWhHo on line 11 Warning: Undefined variable $j in /in/DWhHo on line 22 Warning: Undefined variable $j in /in/DWhHo on line 23 Deprecated: substr(): Passing null to parameter #2 ($offset) of type int is deprecated in /in/DWhHo on line 23 Warning: Undefined variable $j in /in/DWhHo on line 24 Warning: Undefined variable $hash in /in/DWhHo on line 25 j:4

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:
46.25 ms | 403 KiB | 8 Q