First up the variable $str is created using single quotes (so the contained variables are not evaluated). eval() is used to turn a string into PHP code, so the in the argument \$str becomes a variable and the value is set to the original value ot $str (note the double quotes this time).
Also remember that variables given values under eval() will retain these values in the main script afterwards.
eval() really confuses me sometimes 😉