Blog Archives

Missing MySQL References in PHP

The following can be used for quick LAMP installation and/or if you are missing MySQL references in PHP.


sudo apt-get install mysql-server
sudo apt-get install apache2
sudo apt-get install php5
sudo apt-get install php5-mysql
sudo apt-get install phpmyadmin


sudo -c "yum install mysql-server"
sudo -c "yum install apache2"
sudo -c "yum install php5"
sudo -c "yum install php5-mysql"
sudo -c "yum install phpmyadmin"

PHP Quick Reference

Escape sequences for print output:

\" - double quote
\' - single quote
\n - new line
\t - tab
\r - carriage return
\$ - dollar sign
\\ - backslash

Max integer and float size (overflow):

//on a 32-bit system
$large_number = 2147483647;
var_dump($large_number);                     // int(2147483647)

$large_number = 2147483648;
var_dump($large_number);                     // float(2147483648)

$million = 1000000;
$large_number =  50000 * $million;
var_dump($large_number);                     // float(50000000000)

//on a 64-bit system
$large_number = 9223372036854775807;
var_dump($large_number);                     // int(9223372036854775807)

$large_number = 9223372036854775808;
var_dump($large_number);                     // float(9.2233720368548E+18)

$million = 1000000;
$large_number =  50000000000000 * $million;
var_dump($large_number);                     // float(5.0E+19)

generate random number:

echo rand() . "\n";
echo rand() . "\n";

echo rand(5, 15);

Get Current Page Name:

function curPageName() {
 return substr($_SERVER["SCRIPT_NAME"],strrpos($_SERVER["SCRIPT_NAME"],"/")+1);

Came across the following on stackoverflow while looking for the PHP equivalent of string.format.

Sprintf (similar to php printf, in c# string.format):

$filter = "content:%1$s title:%1$s^4.0 path.title:%1$s^4.0 description:%1$s ...";
$filter = sprintf($filter, "Cheese");


function format() {
    $args = func_get_args();
    if (count($args) == 0) {
    if (count($args) == 1) {
        return $args[0];
    $str = array_shift($args);
    $str = preg_replace_callback('/\\{(0|[1-9]\\d*)\\}/', create_function('$match', '$args = '.var_export($args, true).'; return isset($args[$match[1]]) ? $args[$match[1]] : $match[0];'), $str);
    return $str;

StackOverflow, “C# String.Format() Equivalent in PHP?”,


If you are unfamiliar with the term; PHP is a very popular open source web development language.

It runs server side like ASP.Net instead of client side like javascript, and has many of the same features also seen with .Net.

Usage wise, it is arguable by many which language is “superior”, but they both have their pros and cons. After using both extensively, I would have to say I am more preferable to .Net, but PHP still has it’s uses.

One major disadvantage though in my opinion, is having to require separate servers or services to utilize both. Although Apache web server is very popular, and the usual choice for delivering PHP content, it is much easier to configure IIS for a windows or .Net developer or admin, and streamlines the process a little more.

I was a little skeptical of using PHP on IIS6, however, I can trustfully say IIS7 is a good alternative to apache for your PHP applications, and would recommend it to anyone migrating from a windows environment or with developer staff that is cross-platform.

See references below for link to install and configure including a nice PHP Manager which plugs right in to your IIS management interface.

IIS.Net, “PHP on IIS7”,, “PHP Manager for IIS”,
Wikipedia, “PHP”,