Print any PHP variable easily

PHP developers often need to print value of different variables directly to the HTML code. But very often PHP variable is out of the current scope, so the echo(); function doesn’t help. This PHP function prints any global (or external scope) variable by its name:

function print_var($var = 'domain', $url = '')
{
  global $$var, $$$var;
  if ($url != '')
    echo("<a href=\"$url\">${$var}</a>");
  else
    echo(${$var});
}

If you pass some URL as a second parameter you’ll get a clickable link:

<?php print_var('page') ?>
<?php print_var('domain', '/') ?>
<?php print_var('software', '/download/') ?>
<?php print_var('site', 'http://www.site.com') ?>

We hope this PHP hack will be useful for everybody 🙂

States List for USA and Canada

Same to the countries list we are publishing the list of USA and Canadian states.

States list

Hint: Click on list, press Ctrl+A to select all, Ctrl+C to copy the list.

ISO 3166 Country Names

Every time programmers create the user panel in some program or website they have to search for a list of countries for dropdown or listview control. It is annoying…

So we’ve decided to palace such list in a public place. This is ISO 3166 Country Name list. You can freely use it in own projects.

Country Names

Hint: Click on list, press Ctrl+A to select all, Ctrl+C to copy the list.