Is there a way to check in a php script if exec()
is enabled or disabled on a server?
php phpinfo(); ?> You can search for disable_functions and if exec is listed it means it is disabled. To enable it just remove the exec from the line and then you need to restart Apache and you will be good to go. If exec is not listed in the disable_functions line it means that it is enabled.
The pcntl_exec() function works exactly like the standard (unix-style) exec() function. It differs from the regular PHP exec() function in that the process calling the pcntl_exec() is replaced with the process that gets called. This is the ideal method for creating children.
This will check if the function actually works (permissions, rights, etc):
if(@exec('echo EXEC') == 'EXEC'){ echo 'exec works'; }
if(function_exists('exec')) { echo "exec is enabled"; }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With