LoginSignup
8
9

More than 5 years have passed since last update.

PHP chmod関数の第2引数に渡す8進数は、絶対に文字列リテラルにしてはいけない。絶対にだ。

Posted at

こんな風に書くと、

wrong.php
<?php
    chmod('hoge', '0755');

hogeディレクトリのパーミッションは

wrong-result.txt
d-wxrw--wt

こうなってしまう(しかもエラーになったりもしない)。
正しくはこう。

right.php
<?php
    chmod('hoge', 0755);

今度は正しいパーミッションに変更される。

right-result.txt
drwxr-xr-x
8
9
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
8
9