How do I correct the code in php? [closed]

You are mixing html and php content. You should write it like this:

<?php 

function thumbImg() {
   if ( has_post_thumbnail() ) {
       the_post_thumbnail( array(54,54) );
   } else {
       echo "<img src="https://wordpress.stackexchange.com/questions/216047/{$data["featured_img']}' alt="".get_the_title()."" />";
   }
} 

?>

This way, you don’t need to open and close again the php tag.