Why php code does not work with else?

Hello, prompt please why does not want to trigger the code with the else? Appears white screen after adding the else statement where the syntax error?

<?php if( is_front_page() ) { ?>
 <div class="header-page clearfix">
 <h2 class="name-page">Promotions</h2><a href="#" class="cart-btn">
 <div class="cart-btn__img"><img src=" <?php echo esc_url( get_template_directory_uri() );?>/img/shopping-bag.svg" alt></div>
 <div class="cart-btn__text">Your cart</div></a>
</div>


 <? } ?>
 <?php else { ?>
the <div>AAAAAAA</div>
 <?php } ?>
July 2nd 19 at 13:33
2 answers
July 2nd 19 at 13:35
Solution
<?php if ( is_front_page() ) : ?>
 <div class="header-page clearfix">
 <h2 class="name-page">Promotions</h2><a href="#" class="cart-btn">
 <div class="cart-btn__img"><img src=" <?php echo esc_url( get_template_directory_uri() );?>/img/shopping-bag.svg" alt></div>
 <div class="cart-btn__text">Your cart</div></a>
</div>
<?php else: ?>
the <div>AAAAAAAAAAAAAAAA</div>
<?php endif; ?>
Plus only the lack of echo and the use of alternative syntax - rylan_Beer commented on July 2nd 19 at 13:38
July 2nd 19 at 13:37
Solution
Do not rely on the correctness and security of code, but I would have sold so, if the code is small.

I hope people in the know explain if this code is not correct.
<?php 
 if( is_front_page () ) {
 echo ('<div class="header-page clearfix"-->
 <h2 class="name-page">Promotions</h2>
 <a href="#" class="cart-btn"><div class="cart-btn__img"><img src="'.get_template_directory_uri().'" img shopping-bag.svg" alt></div>
 <div class="cart-btn__text">Your cart</div></a>
');
} else {
 echo ('<div>AAAAAAAAAAAAAAAA</div>');
}
?>
in this respect, all the TSA rules - rylan_Beer commented on July 2nd 19 at 13:40

Find more questions by tags PHP