Skip to content

Instantly share code, notes, and snippets.

@Firehed
Created July 3, 2013 07:00
Show Gist options
  • Save Firehed/5915974 to your computer and use it in GitHub Desktop.
Save Firehed/5915974 to your computer and use it in GitHub Desktop.
Print a filtered list of PHP constants. Usage: php con.php [-k keyfilter] [-v valuefilter]
<?
$x = get_defined_constants();
list($kf,$vf) = array_values(getopt('k:v:'));
foreach ($x as $k =>$v) {
if ($kf !== null && 0 !== stripos($k, $kf)) continue;
if ($vf === null || $v == $vf) echo "$k:$v\n";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment