Add Nexttag to php function file

I am trying to add the <!--nexttag--> to a string in my functions.php file, but whenever I add it, it does not seem to be interpreting it and adding it as html. If I write it as '<!--nextpage-->'; it prints <!--nexttag--> on the screen and if I write it as <!--nexttag--> the php seems to ignore it altogether. Here is the total php I'm trying to create:

//* Add Adsense Inside of Posts 

add_filter( 'the_content', 'addsense_code' );
function addsense_code( $content ) {

if (!wp_is_mobile())
{
	$ad_before = '<div id="postWedgeLeft">
<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!-- PantrySpa Above Nav Buttons Desktop -->
<ins class="adsbygoogle"
     style="display:inline-block;width:728px;height:90px"
     data-ad-client="ca-pub-7412812612421318"
     data-ad-slot="5829150038"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>
</div>';
}
else if (wp_is_mobile())
{
	$ad_before = '<div id="postWedgeLeft">

<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!-- PantrySpa Middle Article 336x280 -->
<ins class="adsbygoogle"
     style="display:inline-block;width:336px;height:280px"
     data-ad-client="ca-pub-7412812612421318"
     data-ad-slot="9531324037"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>
</div>';
}

    $contentWithAds = '';
    $contentWithoutAds = explode("<!--nextpage-->", $content);

    if ( count($contentWithoutAds) > 1)
    {
    for ($i = 0; $i <count($contentWithoutAds); $i++) {
          $contentWithAds .= $contentWithoutAds[$i];
          $contentWithAds .= $ad_before;
        }
   }
  else
  {
   $contentWithoutNext = explode("</p>", $content);

    for ($i = 0; $i <count($contentWithoutNext); $i++) {
         if ( count($contentWithoutNext) == $i+1)
         {
          $contentWithAds .= $contentWithoutNext[$i];
          $contentWithAds .= $ad_before;
          $contentWithAds .= '<!--nextpage-->';
         }
         else
         {
          $contentWithAds .= $contentWithoutNext[$i];
          $contentWithAds .= $contentWithoutNext[$i+1];
          $contentWithAds .= $ad_before;
          $contentWithAds .= '<!--nextpage-->';
         }
     }

  }

return $contentWithAds;

}