PHP – Check if exec() function is available

/**
 * Check if exec() function is available
 *
 * @return boolean
 */
function execEnabled()
{
	try {
		// make a small test
		exec("ls");
		return function_exists('exec') && !in_array('exec', array_map('trim', explode(', ', ini_get('disable_functions'))));
	} catch (\Exception $ex) {
		return false;
	}
}