How to insert Google Adsense Code in PHP script?



PHP Snippet 1:

$adsence = " 
<div class=\"right-inner\">
            <center width=\"96% class=\"img-responsive center-block\">
                            <script async src=\"//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js\"></script>

<!-- quiz_net -->
              <ins class=\"adsbygoogle\"
                 style=\"display:block\"
                 data-ad-client=\"$client\"
                 data-ad-slot=\"$slot\"
                 data-ad-format=\"auto\"></ins>
              <script>
              (adsbygoogle = window.adsbygoogle || []).push({});
              </script>
            </center>     
</div>";

echo $adsence;

PHP Snippet 2:

$adsense = "0"; // 0 - For unactivate , 1 - For activate
$ads_client_id = "ca-pub-1234567890123456"; // Publisher ID
$ads_slot_id   = "123456789"; // Slot ID
$ads_format    = "auto"; // ADS format - auto (This ad unit can automatically adjust the size of space available on the page.)

PHP Snippet 3:

<?php if($adsense == 1){
echo "<script async src=\"//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js\"></script>
<ins class=\"adsbygoogle\"
     style=\"display:block\"
     data-ad-client=\"{$ads_client_id}\"
     data-ad-slot=\"{$ads_slot_id}\"
     data-ad-format=\"{$ads_format}\"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>";
}
?>

PHP Snippet 4:

<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<script>
     (adsbygoogle = window.adsbygoogle || []).push({
          google_ad_client: "ca-pub-1325790438113768",
          enable_page_level_ads: true
     });
</script>