I’m trying to put the a defualt logo in WP theme using if, else condition. But doesn’t working

Solution:

Try it like this..

if( has_custom_logo() ){
   the_custom_logo();
}
else{ ?>
   <img src=" <?php echo get_template_directory_uri(); ?>/img/logo.png"        alt="">
<?php }