There is a workaround for the reference problem:
instead of:
<?php
$rot13 = str_rot13($str);
?>
do
<?php
$rot13 = str_rot13($str . "");
?>
In that case str_rot13() won't treat the value as a variable, but more as "hard-coded" (and won't pass the variable for reference)
str_replace