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
https://forums.phpfreaks.com/topic/125376-how-to-center-php-code/
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>
'; 

What do you mean? center the actual code in the file or the output?

 

to center it in the file, you can usually highlight all the text and press tab a few times.

 

wayne just said how to center the output.

 

hope that helps.

 

 

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.

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.