Jump to: navigation, search

Php chmod

From w3cyberlearnings

Contents

PHP function chmod

This function changes file permission mode and it is equal to the chmod command in linux.

Syntax chmod

  • file: file name
  • mode: permission mode (4 numbers). Check linux file permission mode:linux file permission.
    • the first number is always zero
    • the second number is permission for the file owner
    • the third number is permission for the group of the file owner
    • the fourth number is permission for the everyone else.
chmod(file, mode);

Example 1

<?php 
  chmod("myfile.txt",0777);
  // everyone has read, write, and execute to the file.
  // in linux command: $chmod 0777 myfile.txt
?>

Example 2

<?php 
  chmod("myfile.txt",0740);
  // owner (execute,write, and read), owner group (read only), the rest nothing
  // in linux command: $chmod 0740 mytest.txt
?>

Related Links


basename-- chgrp-- chmod-- chown-- clearstatcache-- copy-- delete-- dirname-- disk_free_space-- disk_total_space-- diskfreespace-- fclose-- feof-- fflush-- fgetc-- fgetcsv-- fgets-- fgetss-- file_exists-- file_get_contents-- file_put_contents- file-- fileatime-- filectime-- filegroup-- fileinode-- filemtime-- fileowner-- fileperms-- filesize-- filetype-- flock-- fnmatch-- fopen-- fpassthru-- fputcsv-- fputs-- fread-- fscanf-- fseek-- fstat-- ftell-- ftruncate-- fwrite-- glob-- is_dir-- is_executable-- is_file-- is_link-- is_readable-- is_uploaded_file-- is_writable-- is_writeable-- lchgrp-- lchown-- link-- linkinfo-- lstat-- mkdir-- move_uploaded_file-- parse_ini_file-- parse_ini_string-- pathinfo-- pclose-- popen-- readfile-- readlink-- realpath_cache_get-- realpath_cache_size-- realpath-- rename-- rewind-- rmdir-- set_file_buffer-- stat-- symlink-- tempnam-- tmpfile-- touch-- umask-- unlink--

Navigation
Web
SQL
MISC
References