|
Insert AdSense in PHPIf you want to dynamically insert AdSense in PHP pages, you have to be careful not to modify any AdSense code or you will be violating the AdSense TOS... If you want to simply put the AdSense code you got from Google in a static php page (static meaning not changing), then treat it like html code. However in this article we'll focus on making AdSense code part of the php code. To insert AdSense in PHP you have to be careful not to change Google's javascript code. For example, if you try to use the echo php command to display the code, it will not work. That is because the quote marks (") in javascript code need to be changed to /". DO NOT change it though. Instead you are going to use the heredoc php string creation. Heredoc lets php display code without making any changes to it. For example: echo <<<HERE The trick is to make sure to have no extra space in those lines. Meaning no indenting. Thus you can dynamically insert AdSense in PHP without modifying the code. As long as the code remains intact, Google will not penalize you for violating the TOS. |