Example
Encoding and decoding String:
<?php echo str_rot13("Hello World"); echo "<br>"; echo str_rot13("Uryyb Jbeyq"); ?>
Definition and usage
str_rot13() FunctionCharacter The string performs ROT13 encoding.
ROT13 encoding is obtained by moving each letter forward 13 letters in the alphabet. Numeric and non-alphabetic characters remain unchanged.
Tip: Encoding and decoding are both done by the same function. If you pass an encoded string as a parameter, 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 a ROT13 encoded string. |
PHP Version: | 4.2.0+ |
Change Log: | Prior to PHP 4.3, strings could be modified as if passed by reference. |
Example
Encode and then decode the string:
<?php echo str_rot13("I love Shanghai"); echo "<br>"; echo str_rot13("V ybir Funatunv"); ?>
Result:
"; echo str_rot13("V ybir Funatunv"); ?>
The above is the detailed content of PHP performs ROT13 encoding function str_rot13() on strings. For more information, please follow other related articles on the PHP Chinese website!