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.
![]() |
Refactoring some client code the other day I found a lot of inefficient logic. Whilst this example is written in PHP the concept is applicable in other programming languages.
Many people use for loops in the belief that they are faster than a foreach, and while this is often the case it can be slower and less flexible if you make some simple mistakes. Consider the following:
A slow FOR loop
A faster FOR loop
The second loop is faster because it does not evaluate the string length each time the loop runs strlen($text) as in the first example. Small differences like this can have a large effect on the speed of scripts especially if there are many loops or iterations.
![]() |
EMERGENCY PHP UPDATES
We will be applying a PHP update to the servers later this evening.
This will take the primary PHP install from v5.3.9 to v5.3.10 and will resolve a vulnerability that has been patched in the 5.3.10 release.
The vulnerability present in 5.3.9 allows for the possibility of remote code execution depending on how large numbers and arrays are used.
As this is a security issue we will be performing emergency maintenance between midnight and 3am (GMT).
There should be no interruption to service however, as the work is being done on components critical to PHP based sites, this period should be considered at risk.
The work will cause slightly higher than normal load on the servers and may involve a restart of the web server.
In the worst cast scenario (such as a failed compile) the installer will restore a backup of the current working configuration.
No module or configuration changes will be made to the PHP stack and scripts should notice no difference.
You can view the change log on the php.net site: http://php.net/ChangeLog-5.php
![]() |
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