NOVINKA: Najžiadanejšie rekvalifikačné kurzy teraz s 50% zľavou + kurz AI ZADARMO. Nečakaj, táto ponuka dlho nevydrží! Zisti viac:

PHP - chmod

Trieda

Koreň \ Bez triedy

Metóda - chmod

(PHP 4, PHP 5, PHP 7)

This function allows to change the access permissions (mode) to the file or directory.

Note: The current user is the user under which PHP runs. It's probably not the same user you use for regular shell or FTP access. The mode can be changed only by the user who owns the file on most systems.

Note: This function doesn't work on remote files because the file to be examined must be accessible via server's filesystem.

Note: When the safe mode is enabled, PHP checks whether the files or directories you are about to operate on have the same UID (owner) as the script that is being executed. In addition, you cannot set the SUID, SGID and sticky bits.

Procedurálne

  • function chmod (string $filename, int $mode) : bool

Parametre

NázovDátový typPredvolená hodnotaPopis
$filenamestring

The path to the file.

$modeint

The mode is specified as a value in an octal system - it always starts with zero. Then there are 3 numbers where the first number specifies the access rights for the file owner, the second one for the group of system users and the third one for all other users.

The values of access permissions:

  • 0 - no permissions
  • 1 - execute
  • 2 - write
  • 4 - read

In order to use multiple access rights, just add up the numbers. For example, 0600 would mean read and write for the owner of the file.

Mávratovej hodnoty

Vracia: bool

Returns true on success or false on failure.

Príklady

<?php
    $file= "file.txt";
    // sets the permissions to write and read only for the owner
    chmod($soubor,0600);

Súvisiace manuály

        Aktivity