/ Published in: PHP

This function was respectfully borrowed from TextMate and ported to PHP. Thanks to Allan Odgaard for the function! ;)
Obviously, this can be extended a lot more, but I wanted to keep it as simple as possible for the example.
Obviously, this can be extended a lot more, but I wanted to keep it as simple as possible for the example.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
/** * Returns a rot13 encrypted string as well as a JavaScript decoder function. * @param string $inputString The string to encrypt * @return string An encoded javascript function */ function js_rot13_encode($inputString) { return <<<EOF <script type="text/javascript"> /*<![CDATA[*/ document.write("$rotated".replace(/[a-zA-Z]/g, function(c){return String.fromCharCode((c<="Z"?90:122)>=(c=c.charCodeAt(0)+13)?c:c-26);})); /*]]>*/ </script> EOF; // N.B Make sure there are no whitespace or extra characters following the semicolon above! } // ======== // = Demo = // ========
Comments
