I'm using a php script to hold my adsense code for display, like so:
$ad_header_1 = "
<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<ins class="adsbygoogle"
style="display:inline-block;width:320px;height:50px"
data-ad-client="ca-pub-0000000000000000"
data-ad-slot="0000000000"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>
";
Because this code has "
symbols I have to escape them with a \
, but is it valid/correct to change the DoubleQuote for a SingleQuote instead of having to escape them?
Yes, you can alter the outside double quotes to single quotes IF you are not relying on any variables being evaluated within the string.
So in your case, you can use single quotes to wrap your string.
$ad_header_1 = '
<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<ins class="adsbygoogle"
style="display:inline-block;width:320px;height:50px"
data-ad-client="ca-pub-0000000000000000"
data-ad-slot="0000000000"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>
';
In this way you can use your google adsense script