PHP str_rot13() Function

Example

Encode and decode the string:

<?php
echo str_rot13("I love Shanghai");
echo "<br>";
echo str_rot13("V ybir Funatunv");
?>

Running Instance

Definition and Usage

The str_rot13() function performs ROT13 encoding on the string.

ROT13 encoding moves each letter in the alphabet forward by 13 letters. Numbers and non-alphabetic characters remain unchanged.

Tip:Encoding and decoding are both done by the same function. If you pass the encoded string as an argument, the original string will be returned.

Syntax

str_rot13(string)
Parameters Description
string Required. Specifies the string to be encoded.

Technical Details

Return Value: Returns the ROT13 version of the encoded string.
PHP Version: 4.2.0+
Update Log: Before PHP 4.3,string Can also be modified, just like by reference passing.