PHP str_rot13() Function

Definition

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

Syntax

PHP str_rot13() Function has the following syntax.

str_rot13(string)

Parameter

ParameterIS Required Description
stringRequired.String to encode

Return

PHP str_rot13() Function returns the ROT13 version of the encoded string

Note

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.

Example

Encode and decode a string:


/*  w  ww.  ja v  a 2  s . c  o m*/
<?php
echo str_rot13("java2s.com");
echo "\n";
echo str_rot13("Uryyb Jbeyq");
?>

The code above generates the following result.





















Home »
  PHP Tutorial »
    Function reference »




PHP Array Functions
PHP Calendar Functions
PHP Class Functions
PHP Data Type Functions
PHP Date Functions
PHP File Functions
PHP Image Functions
PHP Math Functions
PHP MySQLi Functions
PHP SimpleXML Functions
PHP String Functions
PHP XML Functions
PHP Zip Functions