3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php function getConstantName($category, $constantNumber) { foreach (get_defined_constants() as $key => $value) { if (strlen($key) > strlen($category)) { if (substr($key, 0, strlen($category)) === $category) { if ($value === $constantNumber) { return $key; } return null; } } } } var_dump( getConstantName('IMAGE', 1) );
based on TIPOr
Output for 4.3.0 - 7.2.0
string(13) "IMAGETYPE_GIF"