str_rot13() Function Use in PHP 8.4 and PHP 8.5

str_rot13() behaves exactly the same in PHP 8.4 and 8.5 as it did in all previous PHP 8.x versions. There are no new changes, deprecations, or behavioral shifts for this specific function in either release.

Examples of str_rot13() in PHP 8.4 / 8.5.

Example 1: Basic Encode & Decode

<?php
$text = "Hello World";

$encoded = str_rot13($text);
echo "Encoded: $encoded ";   // Uryyb Jbeyq

$decoded = str_rot13($encoded);
echo "Decoded: $decoded ";   // Hello World
?>

Output:

Encoded: Uryyb Jbeyq
Decoded: Hello World

Notice: ROT13 is symmetric — same function encodes and decodes.

Example 2: Numbers & Symbols Stay Unchanged

<?php
$text = "PHP 8.4 is 100% fun!";

echo str_rot13($text);
// CUC 8.4 vf 100% sha!
?>

Output:

CUC 8.4 vf 100% sha!
Only letters P, H, P, i, s, f, u, n were shifted. Numbers (8.4, 100), symbols (%, !), and spaces stayed exactly the same.

Example 3: Encrypt Email to Hide from Bots

<?php
$email = "hello@example.com";
$hidden = str_rot13($email);

echo "Hidden : $hidden ";  // uryyb@rknzcyr.pbz
echo "Real   : " . str_rot13($hidden) . " "; // hello@example.com
?>

Output:

Hidden : uryyb@rknzcyr.pbz
Real   : hello@example.com

6 Views