I am new to PHP, and combining that language with HTML is more confusing. I am sure there is a simple solution to it but with all the answers out there I still unable to make it work for me.
Here is the piece of code. I have an if statement that checks for x_filter, if its true it saves its value in $var. 
My problem: I need to rend the value of that $var, once the next if statement, which looks for x_detail, is true. The code as is will not render anything, and also not give any errors and I can't understand why? Any input is much appreciated.
<?php if ($strName == 'x_filter'): ?>
  <?php $var = $this->{$strName}; ?>
  <?php echo $var; ?>
  <!--The echo statement produces the correct value here -->
<?php endif; ?>
<?php if ($strName == "x_detail"):  ?>
  <span class="filter_value">Value of variable should be here: <?= $var; ?></span>
<?php endif; ?> 
    