68 users online (0 members and 68 guests)  


  Results 1 to 5 of 5

Related

  1. Replies: 8
  2. print "Location... in firefox not working    Forum: CGI Perl Forum
    Replies: 1
  3. Replies: 1
  4. Javascript - Convert int to char (1 -> "001")    Forum: Javascript Forum
    Replies: 1
  1. #1
    HTML's Avatar
    Administrator

    Status
    Offline
    Join Date
    Aug 2000
    Posts
    3,445

    Follow HTML On Twitter Add HTML on Facebook Add HTML on Google+ Add HTML on Linkedin Visit HTML's Youtube Channel

    adsense javascript in php "print"

    I have repeatedly told you folks that I am clueless when it comes to scripting, so here I am

    I want to include the google adsense code in php code.

    adsense:
    Code:
    <p align="center">
    <script type="text/javascript"><!--
    google_ad_client = "xxxxxxxxxxxxxxx";
    google_ad_width = 728;
    google_ad_height = 90;
    google_ad_format = "728x90_as";
    google_color_border = "FFFFFF";
    google_color_bg = "FFFFFF";
    google_color_link = "0000FF";
    google_color_url = "0000FF";
    google_color_text = "000000";
    //--></script>
    <script type="text/javascript"
      src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
    </script></p>
    I would like to place it after the following php code
    PHP Code:
    print "<yaddayaddayadda>\n"
    Last edited by HTML; 09-05-2003 at 05:17 PM.

  2. #2
    QuietDean's Avatar
    Administrator

    Status
    Offline
    Join Date
    Oct 2000
    Location
    Bournemouth, UK
    Posts
    2,662
    Quick primer on interpolation.

    when you print or echo in PHP, it gets interpreted one of two ways.

    Example 1, using "" -

    Code:
    echo "my name is $name";
    using the double-quote character, variables within get interpreted and replace. So the output (if $name == 'Dean') would be [My name is Dean]

    using this code instead, using single quotes, the variables are not interpreted -

    Code:
    echo 'My name is $name';
    would output [My name is $name]

    The upshot of this is that if your output contains no php variables, then you can surround it using single quotes and any double quotes inside will work fine. So your code would be
    Code:
    echo '
    <p align="center">
    <script type="text/javascript"><!--
    google_ad_client = "xxxxxxxxxxxxxxx";
    google_ad_width = 728;
    google_ad_height = 90;
    google_ad_format = "728x90_as";
    google_color_border = "FFFFFF";
    google_color_bg = "FFFFFF";
    google_color_link = "0000FF";
    google_color_url = "0000FF";
    google_color_text = "000000";
    //--></script>
    <script type="text/javascript"
      src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
    </script></p>
    ';
    Hope that helps
    If one of our members helps you, please click the icon to add to their reputation!
    No support via email or private message - use the forums!
    Before you ask, have you Searched?

  3. #3
    HTML's Avatar
    Administrator

    Status
    Offline
    Join Date
    Aug 2000
    Posts
    3,445

    Follow HTML On Twitter Add HTML on Facebook Add HTML on Google+ Add HTML on Linkedin Visit HTML's Youtube Channel
    very useful info, thanks

    While on the topic, how does one know when to use print and when to use echo?

    Dave

  4. #4
    QuietDean's Avatar
    Administrator

    Status
    Offline
    Join Date
    Oct 2000
    Location
    Bournemouth, UK
    Posts
    2,662
    The only real difference is that Print() returns an exit value, echo does not.

    So you can check for whether its worked or not. For most intents and purposes, echo works fine, but so does print. So whatever suits

    oh, useful link for the technical stuff -

    http://www.faqts.com/knowledge_base/view.phtml/aid/1/fid/40
    If one of our members helps you, please click the icon to add to their reputation!
    No support via email or private message - use the forums!
    Before you ask, have you Searched?

  5. #5
    clueless's Avatar
    New User

    Status
    Offline
    Join Date
    Feb 2012
    Posts
    1

    Re: adsense javascript in php "print"

    Hi This info was so helpfull that i havd to singup and say thanks.
    However when i use the example above with this code<p align="center">
    my entier website content is no longuer centered, I'm not sure what i'm not doing right. can somebody help me?



Tags for this Thread