Here you will find details of news, projects, releases and other bits and pieces that we are working on at Boolean.
We hope that you find something of interest amongst the archives.
Code snippets, methodologies and useful links will also be mentioned here.
![]() |
In an update to this post here is another way to obtain the number of likes for a Facebook page.
I’ll assume that you’ve already registered a Facebook application, have downloaded the PHP SDK and have included for use in your code.
Setup an array with your Facebook applications credentials
Decide which page you wish to obtain the number of likes for
Obviously you can consume, contrast and display this information in more exciting ways than simply echoing it to the screen. Enjoy.
![]() |
All URLs on Gravatar are based on the use of the hashed value of an email address. According to their best practice you should:
Of course in PHP this is trivial as the following function shows:
Profiles are also available if you require them.
| |
Occasionally a webhost will block the very useful phpinfo() command making it difficult to understand any limitations of the server configuration. This script can display relevant information to help you understand what is happening behind the scenes.
if(!is_null($d_func) && $d_func !== “”){echo “Disabled Functions: \n $d_func”;}
if(!is_null($safe_mode) && $safe_mode !== “”){echo “<span style=’color:red;’>Safe Mode is Active</span> <br>”;}
if($up_max >= 1001){$up_max = $up_max / 1024; $up_max_size = “Gigabytes”;
if($up_max >= 10001){$up_max = $up_max / 1024; $up_max_size = “Terabytes”;}}
if($post_max >= 1001){$post_max = $post_max / 1024; $post_max_size = “Gigabytes”;
if($post_max >= 10001){$post_max = $post_max / 1024;$post_max_size = “Terabytes”;}}
if (min($input_max,60)){$input_max = $input_max /60;}
if (min($exec_time,60)){$exec_time = $exec_time /60;}
if($mem_limit >= 1001){$mem_limit = $mem_limit / 1024; $mem_limit_size = “Gigabytes”;}
echo “Maximum Upload Size = $up_max $up_max_size<br>”;
echo “Maximum Post Size = $post_max $post_max_size <br>”;
echo “Maximum Input Time = $input_max minute/s<br>”;
echo “Memory Limit = $mem_limit $mem_limit_size<br>”;
echo “Maximum Execution Time = $exec_time minute/s<br>”;
?>
![]() |
Alternating row colours within a grid of data can make for a more pleasant viewing experience and has become a popular styling method in recent times. I was a little incredulous at some code I saw recently to determine alternating rows so without further introduction, meet the Modulo operator which is a quick and easy way to get up and running:
I’m sure you will be able to apply this to your own css or styling within your loops.
![]() |
Sometimes you might want to determine a remote file size prior to determining further action to take. This is a quick function that utilises cURL to retrieve the file size in bytes.
Usage is simple:
|
Facebook Like and Share count can easily be obtained from the Facebook Graph API. This is an extremely quick way to look up the JSON response from Facebook so that you can further process it for your own requirements.
echo “Number of likes for CocaCola’s Facebook Page = “.$Likes.”</br>”;
$URL2 =’https://graph.facebook.com/http://www.coca-cola.com’;
$JSON2 = file_get_contents($URL2);
$Output2 = json_decode($JSON2);
$Shares = 0;
if($Output2->shares){
$Shares = $Output2->shares;
}
echo “Number of shares for coca-cola.com = “.$Shares;
?>
UPDATE 29/01/2012: I’ve written a slightly different method using the PHP SDK in this post here
![]() |
Just a quick and dirty PHP function to retrieve information from the Yahoo Finance API to perform a currency conversion
if ($Handle) {
$Result = fgets($Handle, 4096);
fclose($Handle);
}
$allData = explode(‘,’,$Result);
$Value = $allData[1];
return $Value * $Amount;
}
Usage:
![]() |
Often for testing the efficieny of some PHP code we use script execution calculations such as the microtime function. What is infinitely more useful however is the ability to time the execution of all, some, or multiple sections of code or series of lines.
Unfortunately I cant remember the origins of this timer class – but this code allows you to stop, start, pause and resume timing of specific sections of your php code. Thank you, whoever you may be.
Download the class here
Available methods:
start() – start/resume the timer
stop() – stop/pause the timer
reset() – reset the timer
get([$format]) Which can defaults to Timer::SECONDS but can also be Timer::MILLISECONDS or Timer::MICROSECONDS
Usage example:
$timer1->start();
// do some code
// calculate the time it takes to run a function
$timer2->start();
functionX();
$timer2->stop();
$timer1->stop();
print $timer1->get();
print $timer2->get();