The str_rot13() function performs the ROT13 encoding on a string.
PHP str_rot13() Function has the following syntax.
str_rot13(string)
Parameter | IS Required | Description |
---|---|---|
string | Required. | String to encode |
PHP str_rot13() Function returns the ROT13 version of the encoded string
The ROT13 encoding shifts every letter 13 places in the alphabet. Numeric and non-alphabetical characters remains untouched.
Encoding and decoding are done by the same str_rot13() function. If you pass an encoded string, the original string is returned.
Encode and decode a string:
<?php
echo str_rot13("java2s.com");
echo "\n";
echo str_rot13("Uryyb Jbeyq");
?>
The code above generates the following result.