Show DevBest [PHP]Google +1 button script

Status
Not open for further replies.

Dzetki

The Prodigal Son Returns
Jul 16, 2010
990
220
Well, i got really bored and made an EXTREMELY simple +1 button script. But i just remembered that google have several versions of this button. But i will release mine anyways.

PHP:
//put this tag into head, or right before the </body> tag.
<script type="text/javascript" src="https://apis.google.com/js/plusone.js"></script>

//put this code in where you want to show the +1 button. (Can use either $_SERVER['HTTP_HOST'] or $site).
<?php
$site = "localhost";
echo "<g:plusone href='" . $_SERVER['HTTP_HOST'] . "'></g:plusone>";
?>

Like it, +1 it or hate it!
 

Markshall

Русский Стандарт
Contributor
Dec 18, 2010
2,637
2,389
Very nice!
I've adapted your script and made something similar so that you don't have to keep replacing $_SERVER['HTTP_HOST'] with $site if you want to use the $site variable rather than $_SERVER['HTTP_HOST']:

PHP:
<?php
$site = "localhost"; //You only need to change this part - if you want to use $_SERVER['HTTP_HOST'], change this line to: $site = "";
$url  = ( $site ) ? $site : $_SERVER['HTTP_HOST'];
echo "<g:plusone href=\"{$url}\"></g:plusone>";
?>
 
Status
Not open for further replies.

Users who are viewing this thread

Top