Show get_sub_field value if it exists [closed]

You need to make the whole line conditional, like this:

$sub_field_title = get_sub_field('title');
if (!empty($sub_field_title)) {
   echo '<h1 class="title">' . $sub_field_title . '</h1>';
   }

tech