You can check the availability of the function itself:
if(function_exists('shell_exec')) { echo "exec is enabled"; }
By the way, is there a special requirement to use shell_exec rather than exex?
php.net
Note: This function can return NULL both when an error occurs or the program produces no output. It is not possible to detect execution failures using this function. exec() should be used when access to the program exit code is required.
EDIT NO. 1
As DanFromGermany pointed out, you are probably checking to see if it is executable. Something like this would do it
if(shell_exec('echo foobar') == 'foobar'){ echo 'shell_exec works'; }
EDIT No. 2
If the above example may give warnings, you can do it in a more appropriate way. Just see this SO answer .
Christopher will
source share