Starting Scrum from Top to bottom (Bangladesh and Subcontinent)

Currently Scrum is the most popular Agile framework  and many teams are willingly or forcefully adopting it. Since Scrum does not work like a magic tonic and cure all problems, sometimes it can create problems by making everything transparent. Another challenge for adopting scrum is the readiness of the team members or management.

In Bangladesh or any other country in the subcontinent, adopting scrum is a big challenge as we struggle with self managed team concept. we love to follow people rather than taking the lead. we are not aware of our potentials and capabilities. As a result we lack in self esteem and motivations.


If you are planning to adopt scrum at your organization, the following suggestions might be very helpful.

Step 1:

  • Management (CEO, CTO, Directors, Investors etc) must have clear idea about scrum
  • Learn from Agile/Scrum professionals rather than own intuition

Step 2:

  • Start with a small team as pilot project
  • Train the team about scrum paradigm

Step 3:

  • Give team time to understand scrum and try to motivate them to be self managed. As a nation, we are not used to with self management properly.
  • Do not force them to start immediately

Step 4:

  • Run a test or small project for first time
  • Get help from experts during the first few iterations

Step 5:

  • Measure teams output with expected results
  • Try to find out where team is struggling and fix those

Step 6:

  • Keep patience during the whole transformation
  • It can take few weeks to few months for a team to adopt

Step 7:

  • Once the team outputs the expected result, try to repeat it for other teams
  • It can work as a base for others

Step 8:

  • Always plan, execute and adopt. Do not assume that team understood scrum properly and no need to invest time on study
  • Empower team members, give them opportunity to understand themselves

Step 9:

  • Keep a budget for whole transformation
  • You might not get an immediate result during the whole transformation process


Note: these steps might not match with your company structures and flow, so please inspect and adapt 🙂


Add Bangla Font (ex: solaimanlipi) or other ttf font to mpdf

MPDF is a great tool to work with UTF-8 complex texts such as Bangla and indic scripts. You can add your own fonts to MPDF and use it with CSS properties as well.

1. just add this line in your config_fonts.php file inside the mpdf folder (user 6.0 or latest) “solaimanlipi” => array( ‘R’ => “SolaimanLipi.ttf”, ‘useOTL’ => 0xFF, ),

2. copy the solaimanlipi.ttf inside the ttfonts folder.

3. change your css styles for the PDF scripts.

body, p, div { font-size: 14pt; font-family: solaimanlipi;}

h3 { font-size: 15pt; margin-bottom:0; font-family: solaimanlipi; }

4. now run it, you will have the solaimanlipi integrated in mpdf.


you can do it with other unicode font as well

PHP : UTF-8 to Hex String and Hex/Decimal Array

Today I spent a lot time to find a suitable library to convert UTF-8 text (specially Bangla) to hexadecimal values. After spending few hours with other online libraries, I have decided to write my own 🙂 these are pretty handy functions if you are using MPDF to create PDF with UTF-8 strings , specially in Bangla.


function utf8StringToHexString($string) {
$nums = array();
$convmap = array(0x0, 0xffff, 0, 0xffff);
$strlen = mb_strlen($string, “UTF-8”);
for ($i = 0; $i < $strlen; $i++) {
$ch = mb_substr($string, $i, 1, “UTF-8”);
$decimal = substr(mb_encode_numericentity($ch, $convmap, ‘UTF-8’), -5, 4);
$nums[] = “&#x” .base_convert($decimal, 10, 16). “;”;
return implode(“”, $nums);

function utf8StringToHexArray($string) {
$nums = array();
$convmap = array(0x0, 0xffff, 0, 0xffff);
$strlen = mb_strlen($string, “UTF-8”);
for ($i = 0; $i < $strlen; $i++) {
$ch = mb_substr($string, $i, 1, “UTF-8”);
$decimal = substr(mb_encode_numericentity($ch, $convmap, ‘UTF-8’), -5, 4);
$nums[] = “&#x” .base_convert($decimal, 10, 16). “;”;
return $nums;

function utf8StringToDecimalArray($string) {
$nums = array();
$convmap = array(0x0, 0xffff, 0, 0xffff);
$strlen = mb_strlen($string, “UTF-8”);
for ($i = 0; $i < $strlen; $i++) {
$ch = mb_substr($string, $i, 1, “UTF-8”);
$nums[] = mb_encode_numericentity($ch, $convmap, ‘UTF-8’);
return $nums;

My Personal Site

I was planning to move my blog to under my personal domain and it is now available at It will be an exact copy of this site including all posts and contents. I will be maintaining both of the site together to make sure that the visitors have the current information available in the both site.

Please feel free to ask me any questions. Thanks everyone for the support.

Ask PHP/MySQL/Javascript/Web questions!!!

Are you looking for PHP,MySQL,Javascript,Web related answers?

Have you faced difficult questions in your interview?

Are you planning for certification exams and you have questions unanswered?

do you want to correct your reasoning?

Then add questions to this post and you can add as many questions as you want. Every week I will answer or compile the answer for the questions. So lets make the question bank a bigger one.

Atlast our dream project has started!!!

Yes our dream project, “Bangla PHP book” has started last week. Me, Hasin, Emran, Shureed and all those enthusiast developer from PHPXperts group really making it happen. Thanks to Hasin for his initiative and we are very optimistic to bring out a quality book very soon. If anyone is interested, you can join our project. more information on this project can be found here.

My hats off to all the contributors and well wishers of this project. Keep up the good works.

How to SWAP values of two variables without using a third variable (integer) ?

Many times I asked this particular question in the interview session and many people failed to answer. This is just to see the analytic ability of a candidate and how dynamic thinking they have. The logic is same for all programming language, so if you have the logic right then you can answer it for any particular language such as PHP, JAVA, C++, C etc. but in this tutorial We will use PHP 🙂

What if we can use the third variable:

$a = 100;

$b = 200;

now we need to swap the values so that $a becomes 2oo and $b becomes 1oo.

the basic technique is to introduce a third variable $tmp

$tmp = $a;

$a = $b;

$b = $tmp;

isn’t it straight forward. introducing a third variable it is so easy. but what will be our approach if there is no third variable? is it possible?

The answer is a big YES. There are several ways and they fall in two types of solution.

1. Arithmetic operation

2. Bitwise operation.

Arithmetic Operation:

we can use addition-deduction and multiply-division method to solve the problem.

let’s see how addition – deduction method works.


$x = 10;

$y = 20;
$x = $x+$y;
$y = $x – $y;
$x = $x – $y;

it is also very simple, isn’t it. first we are adding the two numbers and keeping the result in one of the variable. in the above example its $x and it contains $x+$y. in the second operation, we are deducting $y from $x and assigning it to $y. now lets break the equation logically

$y = $x – $y => $x + $y – $y => $x  // [ since $x = $x+$y ]

cool, we swapped one of the variable. and following the same operation we are swapping the second one in the third line. so that’s it. It is so easy but just requires some logical thinking. do not try to memorize it rather than understand the simple logic here.

now the multiply-division method:


$x = 10;

$y = 20;
$x = $x*$y;
$y = $x / $y;
$x = $x / $y;

it is same as the addition-deduction method and logic is similar.

now do we see any problem in the above logic? that is the question i ask if someone can answer the question correctly and show me the above solution. 🙂

the answer for that is very simple, it is the number overflow as we always have upper limit for integers. so when we add or multiply two big numbers then the result can cause overflow and might not show desired results.

so what can be a good solution with keeping the overflow fact in mind? the answer is bitwise operation

Bitwise operation:

in order to swap two values we can use the XOR bitwise operator.

Note: A bitwise exclusive or takes two bit patterns of equal length and performs the logical XOR operation on each pair of corresponding bits. The result in each position is 1 if the two bits are different, and 0 if they are the same

the algorithm is

x = x XOR y

y = x XOR y

x = x XOR y

if we write them in computer language using caret (^) then it will look like

x = x ^ y

y = x ^ y

x = x ^ y

in shorter version:

x ^= y

y ^= x

x ^= y

in one line

x ^= y ^= x ^= y

so here is the command in php:

$x ^= $y ^= $x ^= $y

now how it works:

so now we know how to swap two values without using a third variable. ask me any questions you have 🙂

PHP ini issues for scripts running in CLI or executing shell_exec() in *nix

Did you try to run php from command line and faced with php exception like safe mood is on, memory limit exceeded, maximum execution time exceeded etc. A general solution is to edit the php.ini and made those changes and restart apache server. At least i found these solutions online 🙂

But that is not gonna solve your problem. when you are running CLI or shell_exec in *nix environment, php uses a different php.ini file located inside CLI folder. until you edit that the problem wont be solved. So if you are constantly getting errors after altering your php.ini file used by your web server then you should try your CLIs’ php.ini file for any issues regarding cron/CLI.

Running CodeIgniter from Cron/CLI

Many of us faced the problem of running CodeIgniter controllers from Cron or from Command Line. usually we write the following codes to run a php file from cron/CLI.

php /var/www/path/to/your/script

but if we give CodeIgniter Controller path here it will not work since CodeIgniter will fail to initialize its core classes. A work around of this is running the script using CURL

curl http://yourwebsite/controllername

the problem with the above command is that it takes too much CPU resources .

Today my collegue Hasan showed me a nice way of doing it, just write the following codes in a php file in your root folder. here is the way to go

$_GET[“/external/do_cron”] = null;
require “index.php”;

note: here “external” is the controller name and “do_cron” is the function name that you want to execute.

now save this file to any name you want (eg. mycron.php) and run the script using

php /var/www/path/to/script

[here it is php /var/www/mywebsite/mycron.php]

if the above code does not work, you can try the following one. (thanks to sucio)

$_SERVER[“REQUEST_URI”] =”external/do_cron”;
require “index.php”;

Mediawiki Image Gallery Extension – WikiGallery

I was working with MediaWiki Gallery extension named “Smooth Gallery” which is based on JonDesign’s SmoothGallery . It was almost the thing i was looking for but not the exact one for my purpose. As a result I had to hack the code and modify it to fit my needs. You can download the extension and install it for your purpose. I have named it as WikiGallery as lots of things has been changed in this extension. This extension supports external images as well and hence give you more options to create a nice gallery.

A very special thanks to Ryan Lane & Jon

Details of the extension is given below:






Requirements: Mediawiki 1.9.0  and above [ I have not tested with earlier versions. ]


  1. Download the wikigallery files from here.
  2. unzip it to your extensions directory
  3. download wikigallery extension file from here
  4. unzip it and drop it into your extensions directory
  5. make sure $wgUseImageResize is enabled in your LocalSettings.php file
  6. add the following lines to your LocalSettings.php file and save

$wgWikiGalleryExtensionPath = “/mediawiki/extensions/wikigallery”;
$wgWikiGalleryDelimiter = “n”;

Now the extension is ready and we can use it to our wiki pages. Edit a wiki page and add the following tag with image names delimited by the wikigallery delimiter as mentioned on LocalSettings.php file (in this case its n , but it can be , # etc). For local files (uploaded in the wiki), we do not have to put anything. but for external images the http:// must be there.


Now save and check your page , you will see the gallery is there.


  •     I will try to keep the code updated with smooth gallery. But can not promise that.
  •     If you have any download issue, please inform me with your email address. I will send you the scripts in email.