chmod and php

6 views
Skip to first unread message

roja...@gmail.com

unread,
Dec 31, 2007, 10:39:07 AM12/31/07
to Connecticut PHP Developers Group - CPDG
The chmod command (abbreviation of change mode) is a unix command that
will allow to change permissions of a file. This is a very useful when
working with OSCommerce and any application that writes the
configuration files. For security reason you will want to change the
permission to read only.

PHP will allow you to perform this with the native chmod() function.
This function requires 2 parameters to work. The file to change and
the mode (permission).

chmod(string $filename, int $mode)

Lets make a real example here. You want to change the mode to read
only on configuration.php

<?php

chmod('/home/~user/public_html/configuration.php', 0444);

?>

Will

unread,
Jan 2, 2008, 9:42:12 AM1/2/08
to Connecticut PHP Developers Group - CPDG
It is important to note that when entering the $mode, it must be a 4-
digit octal number starting with a 0, unlike the Unix version which is
only three digits.
Reply all
Reply to author
Forward
0 new messages