Jump to content

How to center php code


ForumSecure

Recommended Posts

I am just trying to figure out how to center this code:

 

$result = hs_check_adsense(50);
if($result === false)
{
    $result = array(
        'id'    => 'pub-73783498593',
        'slot'  => '43543563',
        );
}

$ad_code = '<script type="text/javascript"><!--
google_ad_client = "' . $result['id'] . '";
google_ad_slot = "' . $result['slot'] . '";
google_ad_width = 728;
google_ad_height = 90;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
';

 

Please tell me what I need to do to make this centered.

Link to comment
Share on other sites

$result = hs_check_adsense(50);
if($result === false)
{
    $result = array(
        'id'    => 'pub-73783498593',
        'slot'  => '43543563',
        );
}

$ad_code = '<div align="center"><script type="text/javascript"><!--
google_ad_client = "' . $result['id'] . '";
google_ad_slot = "' . $result['slot'] . '";
google_ad_width = 728;
google_ad_height = 90;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div>
'; 

Link to comment
Share on other sites

Yeah, sorry about my previous post, I overlooked that it was a google app that you were adding.

 

The <div align='center'></div> around it will only work on some browsers. Others, like FF3, will just center the contents of the div within the div, and not center it on the page. Try this:

 

Add <div align='center' width='center'> before it, and </div> after it,

OR

add <div style='text-align:center;width:100%;'> before it, and </div> after it.

Link to comment
Share on other sites

Or you could just use horrible syntax to make it compatible in all browsers...?

 

 

$result = hs_check_adsense(50);
if($result === false)
{
    $result = array(
        'id'    => 'pub-73783498593',
        'slot'  => '43543563',
        );
}

$ad_code = '<center><script type="text/javascript"><!--
google_ad_client = "' . $result['id'] . '";
google_ad_slot = "' . $result['slot'] . '";
google_ad_width = 728;
google_ad_height = 90;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></center>
';

 

:/ It's pretty simple when you think about it guys. lol. It might not be the best conventions but center is interpreted by all browsers the same.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.