Further testing of behaviour on Windows vs Linux...



On Linux this function is indeed returning the owner of the script. If you want to know the username PHP is running as you can use POSIX functions (or shell_exec with 'whoami').



On Windows this function is returning the username PHP is running as. Both for IIS (IUSR) and Apache (SYSTEM - which comes from the fact Apache is a service on Windows).



The behaviour on Windows is actually useful given that POSIX functions aren't available. If you need to find the owner of the script on Windows perhaps the best way is to shell_exec to use dir /Q, and parse that.