ForumSecure Posted September 22, 2008 Share Posted September 22, 2008 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. Quote Link to comment https://forums.phpfreaks.com/topic/125376-how-to-center-php-code/ Share on other sites More sharing options...
F1Fan Posted September 22, 2008 Share Posted September 22, 2008 It doesn't look like you're printing anything to be centered. Quote Link to comment https://forums.phpfreaks.com/topic/125376-how-to-center-php-code/#findComment-648193 Share on other sites More sharing options...
waynew Posted September 22, 2008 Share Posted September 22, 2008 $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> '; Quote Link to comment https://forums.phpfreaks.com/topic/125376-how-to-center-php-code/#findComment-648197 Share on other sites More sharing options...
DamienRoche Posted September 22, 2008 Share Posted September 22, 2008 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. Quote Link to comment https://forums.phpfreaks.com/topic/125376-how-to-center-php-code/#findComment-648200 Share on other sites More sharing options...
ForumSecure Posted September 22, 2008 Author Share Posted September 22, 2008 That code is a modified version of a Google adsense code. I am trying to put it on my website and have the ads centered on the page. Quote Link to comment https://forums.phpfreaks.com/topic/125376-how-to-center-php-code/#findComment-648214 Share on other sites More sharing options...
F1Fan Posted September 22, 2008 Share Posted September 22, 2008 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. Quote Link to comment https://forums.phpfreaks.com/topic/125376-how-to-center-php-code/#findComment-648227 Share on other sites More sharing options...
ForumSecure Posted September 26, 2008 Author Share Posted September 26, 2008 It is a modified Adsense code. I need it centered but when I try to center it then it ends up centering everything else on the page as well. Quote Link to comment https://forums.phpfreaks.com/topic/125376-how-to-center-php-code/#findComment-650942 Share on other sites More sharing options...
redarrow Posted September 26, 2008 Share Posted September 26, 2008 example 1 <center>hi there</center> example 2 <div align="center">hi there</div> example 3 <table align="center"> <tr> <td align="center"> hi there </td> </tr> </table> Quote Link to comment https://forums.phpfreaks.com/topic/125376-how-to-center-php-code/#findComment-650950 Share on other sites More sharing options...
Guest Xanza Posted September 26, 2008 Share Posted September 26, 2008 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. Quote Link to comment https://forums.phpfreaks.com/topic/125376-how-to-center-php-code/#findComment-650973 Share on other sites More sharing options...
redarrow Posted September 26, 2008 Share Posted September 26, 2008 if u need it cross browser c0mpatable use css, javascript dosent make anythink compatable lol sorry.... xanza..... where u here that from mate! Quote Link to comment https://forums.phpfreaks.com/topic/125376-how-to-center-php-code/#findComment-650979 Share on other sites More sharing options...
Guest Xanza Posted September 26, 2008 Share Posted September 26, 2008 Test it.... $something = "<center>This is going to be centered reguardless of input.</center>"; echo $something; Same concept. Quote Link to comment https://forums.phpfreaks.com/topic/125376-how-to-center-php-code/#findComment-650997 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.