Deprecated: I don’t maintain this site anymore …

March 27, 2016

Thanks for reaching out to this site but I am not maintaining this anymore…

I will blog (if I do 🙂 ) at



Shaikhul (Shaymol)


My first Chrome Extension

July 24, 2010

Yesterday i was playing with chrome extension. I search for a tutorial and found that google provides the best and easy tutorial to build a chrome extension. When i have done with the tutorial i see its too easy to build a chrome extension, prerequisites is only in depth knowledge of Javascript and HTML DOM and built a simple extension that will show today’s bangla date. To get the bangla date it will use a javascript widget from tareq’s site.

Here is a screenshot of the extension

Bangla date chrome extension

You can check this extension from chrome extension directory

Do not reinvent the wheel – anonymous

Handling Fatal Error in PHP way

July 22, 2010

In PHP when any fatal error happen, (ex. Fatal error: Call to undefined function phpinf() .. or .. Class ‘User’ not found etc ..) it stops executing script, as a result a broken page is shown. This is very unexpected behavior to users. So we need to handle this and show an user friendly error message to the browser.

To handle the fatal error and some other errors we can use a method register_shutdown_function which accepts a function name as a param that will be called when current script execution completed. So in case of any fatal error happen, the script execution will end and call the registered method instantly. and thus we can takeover the execution flow and do our custom task, ex. report admin about the error, show user an appropriate error message etc. By the way, this registered method will be called each time current script ends its execution. So in that method we need to check the last error if there is any real error happen. There are many PHP Error Constants.

Here is a simple example

* define the shutdown method, which will be called each time this script execution ends
function shutdown()
// get last error
$lastError = error_get_last();

// show user error message if any error happen
// get error type
$errorType = $lastError['type'];
if(in_array($errorType, $criticalError )){
// mail to admin
// mail('', ....);

// print a proper message to output
echo "Sorry, an unexpected error happen, please check later";

// register the shutdown function

// now do some fatal error like call a class which does not exsits
User::load(); // here User Class is not included

Here is the output ..

Sorry, an unexpected error happen, please check later

The more you do mistake, the more you get the chance to learn 😉

php Classes n Methods are Unicoded ;)

July 21, 2010

wao PHP supports unicoded user defined classes and functions. Try out the following simple code yourself if you dont believe me :D…

class বাংলা{
public function __toString(){
return 'বাংলায় ক্লাস লিখি ;)';

public function হেলও_ওয়ার্ল্ড(){
echo 'আই এম এ হেলও_ওয়ার্ল্ড মেথড :দ ';

$obj = new বাংলা;
echo $obj;
echo $obj->হেলও_ওয়ার্ল্ড();

Here is the output

বাংলায় ক্লাস লিখি ;)
আই এম এ হেলও_ওয়ার্ল্ড মেথড :দ

N.B. This is only for fun 😉 , dont try to use this approach, as your teammate might get puzzled about the class names if she does not understand Banagli 😉

++$city where $city = ‘NY’ ?

July 10, 2010

I have found something about the unary op in PHP. I was checking it in PHP 5.2.1.
Check the following code and guess the output. When you have done check with the answer given below.

echo ++$city , ' '; // think well ;)
echo $city = $city + 1, ' '; // is there any diff ?

$cg = '3.53 is my cg';
echo ++$cg, ' ';
echo $cg = $cg + 1;

Did you get your answer? then check with the following

NZ 1 3.53 is my ch 4.53

Let me explain if not matched with your answer. When php do an unary operation like (++$city) on character variable it follows perl style, its actually increment to next character, say if it is A it will B and so on… so for the example it will be NZ.
But when the same is done by using binary operation (+), in that case first it convert the string into integer (and this is called type juggling ) and in that case it converts it into 0 then do the plus operation, so the output here is 0 + 1 = 1.

So be careful what you actually want and select operator accordingly!


fun with $ in Js

July 10, 2010

have you ever tried with character javascript variable ? trust me i am not kidding ;). javascript supports two special one character variable. one is underscore(_) and another one is ($). Try out in your firebug console.

_ = ' i am an underscore';
$ = ' 6 million dollar man';
alert(_ + ' : ' + $);

Isn’t it interesting ? but dont use it professionally if you are not master in javascript as it would be make others ins puzzle about what the variable means.


did you typecast (array) $obj before ?

July 9, 2010

Today i found an interesting thing in typecasting. We actually typecast float to int, string to int etc. but have you ever tried to typcast an object to an array ? what would it return in that case ? well its very interesting to me. It will return an array with all properties of the object irrespective to access modifiers!

lets have a look in a simple example, say an User class have two property field one is private (userId) and another is public (userEmail) and two setter method, now if we create an instance of that class and set those two fields and then convert it into array, it will return thoese two fields as array index.

class User{
private $userId;
public $userEmail;

public function setUserId($userId){
$this->userId = $userId;

public function setUserEmail($email){
$this->userEmail = $email;

$user = new User();
$userArr = (array)$user;


The above code will result as follows

[UseruserId] => 123
[userEmail] =>

Just look at the private field, it append the Class name with the private property in the array index. and public field is as it is. isn’t it interesting 😉

Happy Phping ….