PHP str_rot13()Function
Example
Encode and decode a string:
<?php
echo str_rot13("Hello World");
echo "<br>";
echo str_rot13("Uryyb Jbeyq");
?>
echo str_rot13("Hello World");
echo "<br>";
echo str_rot13("Uryyb Jbeyq");
?>
Run example »
Definition and Usage
The str_rot13() function performs ROT13 encoding on a string.
ROT13 encoding is obtained by moving each letter 13 letters forward in the alphabet. Numbers and non-letter characters remain unchanged.
Tip:Encoding and decoding are both done by the same function. If you pass an encoded string as the parameter, the original string is returned.
Syntax
str_rot13(string)
| Parameters | Description |
|---|---|
| string | Required. Specifies the string to be encoded. |
Technical Details
| Return value: | Returns the ROT13-encoded string. |
|---|---|
| PHP Version: | 4.2.0+ |
| Changelog: | Before PHP 4.3,stringcould be modified, as if it were passed by reference. |
PHP String Reference Manual Other Extensions