显示数据库中的PHP变量以及HTML

I want to display a row that contains a text and an image saved with a PHP Variable from a database.
Exemple:

Row contains: "Some text about something and then <img src="images/$img">"

When i try to echo it's displaying like a plain text
Exemple:

"Some text about something and then <img src="images/$img">" thus the $img = "test.png" and image should be echo like <img src="images/test.png">

You can replace that substring - but remember to use single quotes not to evaluate $img variable.

$new_string = str_replace('$img', $img, $old_string);

Though it is a bad idea

<?php $img='a.png'; ?> <img src="images/<?php echo $img?>">

Try this :

<?php
$img = 'image.png';
$str = 'Some text about something and then <img src=\"images/$img\">';
eval("\$str = \"$str\";");
echo $str. "
";
?>

But this is not recommended.