When the php.ini directive auto_globals_jit is enabled, $_SERVER and $_ENV super global arrays are created at the time they are first used in the script, rather than being initialized at the start of script. The benefit of this directive is that these super global arrays are not created at all if not used within a script, resulting in a little performance gain.

Continue reading

Since the introduction of register_globals feature in PHP, there was a lot of discussion around the web criticizing this feature as a security risk. There established a perception that all websites on servers having register_globals enabled are insecure and vulnerable to hacking/injection. Consequently, the feature went to Off in PHP 4.2, deprecated in PHP 5.3 and completely removed in PHP 5.4. Even before all this, many web hosts disabled this feature. This caused problems to those not-by-profession PHP coders who rely on ease of use of PHP language to code their business or personal website.

Continue reading

Random numbers functions rand() and mt_rand are easy to use and pretty fast. Numbers produced by these functions range from 0 to PHP_INT_MAX unless you specify your own range. In case you use a custom range, it generates a random number within that range, but – it gets slower.

Continue reading

While we already have trim(), ltrim() and rtrim() in php, here is how we can implement the same feature. These are listed here just for understanding the process. In practice, you are recommended to use the built-in functions for performance and consistency reasons.

Continue reading

ASCII is one of the earliest character encoding scheme providing a way of encoding control characters, commonly used symbols, alphabets and digits. Many modern character encoding schemes extend the character set used by ASCII by providing additional characters so as to not only maintain backward compatibility but also achieve the benefits of encoding more international characters.

Continue reading