PHP str_rot13() Function with Example

PHP str_rot13() Function with Example

PHP str_rot13() Function: Here, we will find out about the str_rot13() Function with Example in PHP.

PHP str_rot13() Function

str_rot13() work is a string capacity, it is utilized to encode (or decipher the encoded string) a string utilizing ROT13 encoding system.

The ROT13 encoding method is utilized to encode just letter sets it doesn’t encode the numbers and other uncommon characters. In ROT13 encoding procedure, every letter in order to move 13 spots in the letters in the order table.

Syntax:

    str_rot13(string);

It acknowledges the string and returns the encoded string by ROT13 encoding procedure

Example:

    Input: "This is JustTechReview"
    Output: "Guvf vf VapyhqrUryc"
    Input: "Guvf vf VapyhqrUryc"
    Output: "This is JustTechReview"
    Input: "Hello 123 %$#@!"
    Output: :Uryyb 123 %$#@!"

PHP Code:

<?php
	$str = "This is JustTechReview";
	$enc_str = str_rot13($str);
	echo ("String = $str \n");
	echo ("Encoded string = $enc_str \n");
	
	//Here, we will convert encoded string 
	//that will be main string
	$str = $enc_str;
	$enc_str = str_rot13($str);
	echo ("String = $str \n");
	echo ("Encoded string = $enc_str \n");

	//string with numbers & alphabets
	$str = "Hello 123 %$#@!";
	$enc_str = str_rot13($str);
	echo ("String = $str \n");
	echo ("Encoded string = $enc_str \n");
?>

Output:

String = This is JustTechReview
Encoded string = Guvf vf VapyhqrUryc
String = Guvf vf VapyhqrUryc
Encoded string = This is JustTechReview
String = Hello 123 %$#@!
Encoded string = Uryyb 123 %$#@!

Recent Posts

error: Alert: Content is protected!!