Results 1 to 2 of 2

Thread: How to get the owner of a file / PHP script with PHP?

  1. #1
    Administrator Kavoir's Avatar
    Join Date
    Dec 2009
    Posts
    183

    How to get the owner of a file / PHP script with PHP?

    To get the file owner of any file under Linux with PHP:

    PHP Code:
    print_r(posix_getpwuid(fileowner($filename))); // $filename is the full path to the file 
    To get the file owner name of the currently active or running PHP script:

    PHP Code:
    print_r(posix_getpwuid(fileowner(__FILE__))); 
    Which would return something like this:

    PHP Code:
    Array
    (
        [
    name] => james
        
    [passwd] => x
        
    [uid] => 1000
        
    [gid] => 1000
        
    [gecos] => ,,,
        [
    dir] => /home/james
        
    [shell] => /bin/bash

    Other than file owner, you can find the process user of a PHP script.
    The road goes ever on and on.

  2. #2
    thanks a lot for this posting, as i new PHP learner , this will be help me a lot

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •