FYI, this function works with class constants too.
Below is an example in which a database abstraction layer creates connections to different relational database systems based on class constants such as DBFission::CONNECTION_MYSQL, DBFission::CONNECTION_POSTGRESQL, etc. Using this function, I can convert text in an INI file to an integer constant easily.
<?php
// php voodoo to get a class constant based on a string
$type = constant( 'DBFission::CONNECTION_' . strtoupper( $c[ 'type']));
?>
connection_timeout