PHP str_rot13() Function
The PHP str_rot13() function performs the ROT13 encoding on the string argument and returns the resulting string.
The ROT13 encoding simply shifts every letter by 13 places in the alphabet while leaving non-alpha characters untouched. Encoding and decoding are done by the same function. Passing an encoded string as argument to this function returns the original version.
Syntax
str_rot13(string)
Parameters
string |
Required. Specify the input string to be encoded. |
Return Value
Returns the ROT13 version of the given string.
Example:
The example below shows the usage of str_rot13() function.
<?php $str = "Hello World!"; //encoding the str $encode_str = str_rot13($str); //decoding the encoded string $decode_str = str_rot13($encode_str); echo "The string is: $str \n"; echo "Encoded string is: $encode_str \n"; echo "Decoding encoded string: $decode_str \n"; ?>
The output of the above code will be:
The string is: Hello World! Encoded string is: Uryyb Jbeyq! Decoding encoded string: Hello World!
❮ PHP String Reference