Bootstrap FreeKB - PHP - Display current user using exec whoami
PHP - Display current user using exec whoami

Updated:   |  PHP articles

exec can be used to run a command on the PHP server. For example, if the PHP server is a Linux system, exec could be used to run Linux command whoami.

<?php
  $whoami = exec("whoami", $output, $return);
  print_r($output);
  echo "whoami = $whoami";
  echo "Return Code = $return"; 
?>

 

Something like this should be returned which shows that you are user www-data.

Array ( [0] => www-data )
whoami = www-data
Return Code = 0

 




Did you find this article helpful?

If so, consider buying me a coffee over at Buy Me A Coffee



Comments


Add a Comment


Please enter 5ab8d2 in the box below so that we can be sure you are a human.