如何将变量与PHP中的字符串一起串起来?

So I have a variable in PHP that I would like to print along with an html tag but I am very new to PHP and I can't seem to get the syntax right

My goal is to output/print the following

<div class="post-block" style="background-image:url(Whatever image here);">

My code is below:

    $feature_posts = the_sub_field('feature_image_post');

      if ( get_sub_field('post-feature') == "" )  {       
        echo '<div class="post-block" style="background-image:url(' .$feature_posts");>';
        echo '</div>'; 
      } 

You can make that.

<?php for($i = 0; $i <= 100; $i++){ ?>
    <div class="post-block" style="background-image:url(<?php echo the_sub_field('feature_image_post') ?>);"></div>

<?php } ?>

This a sample how you can do.

You are missing the concatenation operator and the closing single quote after your variable:

$feature_posts = the_sub_field('feature_image_post');

if ( get_sub_field('post-feature') == "" )  {       
    echo '<div class="post-block" style="background-image:url(' . $feature_posts . ')">';
    echo '</div>'; 
} 

To keep the format more readable you can use double quotes to allow variables in your string. Just have to remember escaping the quotes within the markup:

$feature_posts = the_sub_field('feature_image_post');

if ( get_sub_field('post-feature') == "" )  {       
    echo "<div class=\"post-block\" style=\"background-image:url($feature_posts)\">";
    echo '</div>'; 
}