Test php script to check the exec php function

Simple php script to check if exec php function is enabled or not because many shared hosting provider by default disabled the exec php function to secure the server. You can refer the following script to check exec php function.

Login in to the cPanel and create the new file test.php and insert the following code.

<?php
echo exec(‘whoami’);
?>

Now browse the URL yourdomain.com/test.php , it will show your cPanel user name if exec php function is enabled on the server and if exec php function is disabled on your domain hosted server then you will receive the following error after browsing the URL yourdomain.com/test.php

Warning: exec() has been disabled for security reasons in /home/cpanel_username/public_html/test.php on line 2

You can contact your hosting provider and ask them to enable the exec function. If you have any query let me know at nsk.gunjan@gmail.com

About Anant 384 Articles
Senior technical writer