Why.use.periods?

When I have to put PHP aside for a while and do something else in Java or ASP, sometimes I will forget how to do certain things or which operators are used.

I have a particular beef with the “.” (period) being used as a concatenation operator because it is not as instinctive as the “+” or the “&” used in other languages. “+” makes sense because it implies addition, “&” also makes sense because the effect of the ampersand is similar to “and”. However, can someone tell me the reasoning behind “.”?

Sng Bao, Sng Bao

When I was walking back home during my Primary School days, I would invariably walk past an array of provision shops that displayed all their tempting wares along the walkway to seduce children into parting with their money. During those days when the weather was hot, I would open the freezer and get a “sng bao” (literally translated from Hokkien as “ice packet”) to enjoy on my journey home.

For those not in the know, a “sng bao” is a nunchuk-shaped plastic tubing containing a sweet frozen liquid that was undoubtedly accountable for countless sugar rushes and tooth decay. Think you should still be able to find it being sold at some places.

L-A terrified of cockroaches

In an accidental social experiment with a sample size of 1, I have concluded that children have an innate fear of cockroaches.

This morning, when L-A stepped out of my bedroom, she chanced upon one sluggish cockroach crawling along the hallway and she gave a hearty shout and scream and came running to me. She then proclaimed repeatedly, “Daddy bao bao! L-A scared!”

After the roach was exterminated, Esh and I were bemused. I would have thought that children would have no fear of anything encountered for the first time and maybe would have even picked it up to play with it (or even taste it!) Looks like there is either an instinctual fear or some subconscious social conditioning took place.

Why you might not want to use PHP’s rand() function anymore

If you have been using the rand() function in PHP to generate random numbers for use in your scripts, you might want to consider otherwise. Maybe C programmers might also want a rethink since the PHP rand() function is derived from libc…

Anyway, help is at hand with the mt_rand() function which is syntactically similar but it behaves better. The numbers generated will be more, erm, random. You will also be able to improve random number generation performance by 4 times! Incidentally, the “mt” in “mt_rand()” stands for Mersenne-Twister.

If you are interested in the mathematics behind this, go to this site.

Error Reporting Level for PHP Development

While there are a total of 11 error reporting levels for PHP, the combination I generally use the most often would be

error_reporting (E_ALL | E_STRICT);

The E_ALL argument is somewhat of a misnomer since it does not really include all error types. E_ALL does not include the E_STRICT error type which indicates whether your existing code (which runs perfectly now) may have a problem in future versions of PHP. Although its a never-ending race, developers should still try to future-proof their code as much as possible.