Monday, 29 September 2014

str_rot13 in PHP

PHP str_rot13() function is utilized to perform the rot13 transform on a string.

Syntax:

str_rot13(string)
string : Required. Specifies the input string.

Note: The ROT13 encoding basically moves each letter by 13 places in the letter set whileleaving numeric and non-alpha characters untouched.

Encoding and decoding are both done by PHP str_rot13() function, passing an encoded string as argument will return the original version.

Example:

<?php
$res = str_rot13("Good Morning");
echo $res."<br />";
echo str_rot13($res);
?>
Output will be:
Tbbq Zbeavat
Good Morning

0 comments:

Post a Comment