修改php脚本创建的文件的权限


modify permissions for files created by php script

我如何(或可以)更改以下php script,以便在创建新文件时授予文件r/w权限?

<?php
    if(isset($_GET['data'])) {
        $data = $_GET['data']  . "'n";
        $ip = $_GET['ip'];
        $ret = file_put_contents('/opt/tomcat7/webapps/servlets/WEB-INF/logs/' . $ip, $data, LOCK_EX);
        if($ret === false) {
            die('There was an error writing the lab data file');
        }
        else {
            echo "$ret bytes written to file";
        }
    }
    else {
        die('no data to process');
    }
?>

尝试chmod函数。

例如chmod("/somedir/somefile", 0755)