PHP Include and AdSense

Discussion in 'AdSense' started by zac439, Oct 29, 2007.

  1. #1
    Can we use a PHP include file for our adsense code?

    I wasn't sure if it would screw with the stats Google collects or anything. Or if it was against the TOS.

    For example, just use this where you need an ad:
    <?php include("includes/ad.php"); ?>

    whereas the ad.php file would have your googel adsensecode.
     
    zac439, Oct 29, 2007 IP
  2. live-cms_com

    live-cms_com Notable Member

    Messages:
    3,128
    Likes Received:
    112
    Best Answers:
    0
    Trophy Points:
    205
    Digital Goods:
    1
    #2
    PHP include just echos the contents of the file, I think, so it would be the same as usual.
     
    live-cms_com, Oct 29, 2007 IP
  3. directportrait

    directportrait Active Member

    Messages:
    523
    Likes Received:
    15
    Best Answers:
    0
    Trophy Points:
    90
    #3
    I use php include to call an external javascript file with my Adsense code... never had a problem and my code is neat and clean :)
     
    directportrait, Oct 29, 2007 IP
  4. zac439

    zac439 Notable Member

    Messages:
    3,074
    Likes Received:
    214
    Best Answers:
    0
    Trophy Points:
    260
    #4
    Excellent, thanks. Yeah, I'm really appreciating how much neater my code is right now :D
     
    zac439, Oct 29, 2007 IP
  5. tlainevool

    tlainevool Guest

    Messages:
    1,071
    Likes Received:
    52
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Yes, PHP includes are no problem at all. PHP is all server side, so there is no difference to what the client would see, so that is all the Google cares about.
     
    tlainevool, Oct 29, 2007 IP
  6. ForgottenCreature

    ForgottenCreature Notable Member

    Messages:
    7,473
    Likes Received:
    173
    Best Answers:
    0
    Trophy Points:
    260
    #6
    Yes, you can use php includes. It doesn't effect anything.
     
    ForgottenCreature, Oct 29, 2007 IP
  7. buzza_gts

    buzza_gts Active Member

    Messages:
    199
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    58
    #7
    Could someone correct me if i'm wrong but shouldn't you use require_once() instead of an include as no further PHP code is to be executed in the include?
     
    buzza_gts, Oct 29, 2007 IP
  8. Adulu

    Adulu Peon

    Messages:
    2,791
    Likes Received:
    43
    Best Answers:
    0
    Trophy Points:
    0
    #8
    I think any medthod which will not change any bit adsense source code
    all are allowed
     
    Adulu, Oct 29, 2007 IP
  9. Abhik

    Abhik ..:: The ONE ::..

    Messages:
    11,337
    Likes Received:
    606
    Best Answers:
    0
    Trophy Points:
    410
    Digital Goods:
    2
    #9
    oh yes, its allowed..
    I am doing it for last one year and never have any problem.
     
    Abhik, Oct 29, 2007 IP
  10. zac439

    zac439 Notable Member

    Messages:
    3,074
    Likes Received:
    214
    Best Answers:
    0
    Trophy Points:
    260
    #10
    Can someone answer this? I'm interested in knowing myself...
     
    zac439, Oct 29, 2007 IP
  11. Fry_

    Fry_ Guest

    Messages:
    69
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #11
    I use includes to randomize ad formats. Sure I'm not the only one too. Cant see why they'd have a problem with it.
     
    Fry_, Oct 29, 2007 IP
  12. Timby

    Timby Well-Known Member

    Messages:
    565
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    138
    #12
    I use includes for my navigation, which has adsense on it. I havn't had any problems and i've been a publisher for almost a year now.
     
    Timby, Oct 30, 2007 IP
  13. sultanofseo

    sultanofseo Notable Member

    Messages:
    9,930
    Likes Received:
    405
    Best Answers:
    0
    Trophy Points:
    265
    #13
    i never used php include but have been using SSI with #include and never had any problem. its just like the content of your site once loads
     
    sultanofseo, Oct 30, 2007 IP
  14. SEOWOES

    SEOWOES Peon

    Messages:
    60
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #14
    difference between include(), include_once, require(), require_once -

    the include_once() and require_once() statements ensure that the code is only included once in a loop, and not repeatedly. If you were looping three times, and wanted to display the ads three times, you would use include() or require(). if you wanted to only display the ads the first time through the loop, use include_once() or require_once().

    The difference between include() and require() is in the error handling. include() only raises an error warning, require() raises an error and aborts the process. In other words, require() will terminate the page if it cannot find the specified file.

    hth.
     
    SEOWOES, Oct 30, 2007 IP
  15. baumann93

    baumann93 Peon

    Messages:
    2,268
    Likes Received:
    60
    Best Answers:
    0
    Trophy Points:
    0
    #15
    As others mentioned, include simply echoes the content into a specific area of the page... there is nothing wrong with using include to display adsense ads. I have been using it for years.
     
    baumann93, Oct 30, 2007 IP