首頁  >  文章  >  後端開發  >  php設定index.php檔案為唯讀的方法

php設定index.php檔案為唯讀的方法

WBOY
WBOY原創
2016-07-25 09:05:41911瀏覽
  1. function set_writeable($file_name)
  2. {
  3. if(@chmod($file_name,0555))
  4. {
  5. echo "修改index.php文件只读属性成功";
  6. }
  7. else
  8. {
  9. echo "修改index.php文件只读属性失败,空间商不支持此操作!";
  10. }
  11. }
  12. set_writeable("index.php");
  13. ?>
复制代码

把以上内容保存成setread.php,然后上传到空间,直接浏览器浏览该地址即可设置只读。 不过设置这个只读属性以后,你自己通过ftp也没有权限删除index.php,如果需要删除或者覆盖index.php请使用以下代码设置index.php的读写权限。 下面是设置index.php读写的代码:

  1. function set_writeable($file_name)
  2. {
  3. if(@chmod($file_name,0777))
  4. {
  5. echo "修改index.php文件读写属性成功";
  6. }
  7. else
  8. {
  9. echo "修改index.php文件读写属性失败,空间商不支持此操作!";
  10. }
  11. }
  12. set_writeable("index.php");
  13. ?>
复制代码

保存以上内容为:setwrite.php,通过浏览器访问即可设置读写权限了。



陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn