在php变量上添加alt标签

I am trying to add an alt attribute to my code and failing.

echo "<img src=\"images/{$filmImage}\" alt={$FilmName}\". class=\"rightImg\">";

I'm not quite sure how to do this.

You're missing the first quote for the alt attribute, and you have a . that's not doing anything (probably a remnant from string concatenation)

Try changing your code to this:

echo "<img src=\"images/{$filmImage}\" alt=\"{$FilmName}\" class=\"rightImg\">";