I want to have a php file with all my header and side bars and I was wondering if I could stick the adsense code in that and use an include method to have it on every page. Is this against the TOS? If it isn't, will it even work correctly?
That will work just fine. PHP includes are processed on the server, and therefore this is transparent to any visitor, Google included
And it will still generate ads relevant to the context on that page, correct? And this isn't breaking the TOS in anyway?
Yes and no The way it works is that the PHP is processed first, adding adsense to the site, and then the Javascript which makes the ads runs, making the ads prefectly relevant.
google will never know that you are using the include , they will only see a simple page . and the ads will depend on what there is on the page ..
Why would it break their TOS? It is perfectly valid, and they will never know the difference. When the Googlebot comes around all it will see is the HTML. It cannot look at your PHP because that is server side. As for it affecting your ads: their scripts run completely separately of your server, so you can do virtually whatever you want and not change those. As long as the ads are there, and can be recognized easily by the end user for what they are (IE: not being deceitful about it), then you are good. I'll give it a quick double check for you, but I am 99% positive on this one.
Then later it has a small deal about using scripts to automatically click links for you, but as long as the script doesn't click the links or break the above rules you are good to go. Exactly. I just wanted to prove my point within their TOS.
oh SWEET. This will save so much hassle and it will make changing colors on layouts so much easier. Thanks a lot.
Everyone is doing it.. well not everyone, but everyone who wants to make the ads mobile and time-saving when editing.
Generating content relevant ads based on the context of any page using PHP is i think allowable in the TOS as long as you don't use PHP in tweaking your ads aside from the allowed use of colors and texts in the user CP.