Check if "exec" is disabled

esqew picture esqew · Oct 15, 2010 · Viewed 23.1k times · Source

Is there any function in PHP that I can use to detect whether or not the exec function is available?

Answer

Brent picture Brent · Oct 15, 2010
<?php
function exec_enabled() {
  $disabled = explode(',', ini_get('disable_functions'));
  return !in_array('exec', $disabled);
}
?>

EDIT: Fixed the explode as per Ziagl's comment.