NYCPHP Meetup

NYPHP.org

[nycphp-talk] phantom file writing errors

John Lacey jlacey at att.net
Tue Jul 27 00:30:27 EDT 2004


Marc Antony Vose wrote:

> 
> Hi there:
> 
> The file path is correct.
> 
> I know that the PHP script is creating the files, because I have deleted 
> all the files, and they get created.  So, yeah, I'm 100% certain of 
> that.  This also validates the prior point, about the path.
> 
> The PHP parser is giving me the warning even though it is creating the 
> files...how and why can it do this?
> 
> I mean, I could suppress its output by prepending the '@' sign, but I'd 
> like to be notified of REAL issues in the script...
> 

The ability to create a file and then write to it are two different 
animals because of permissions, and specifically, "umask".  The value in 
umask determines the default permissions for new files created on the 
system.  (we're talking *nix here)

To make things interesting, umask works as an octal complement.  All 
this means is that a value of umask such as "022" will be subtracted 
from the default permissions mask for files (666) yielding a "644".  In 
this case, the owner would have read/write permissions, but anyone in 
the associated group and the rest of the world would have read 
permissions.   "OGW" -- Owner, Group, World  owner="6"; group="4"; world="4"

PHP has filesystem functions that allow you to change the permissions 
here:  (chmod)

http://www.php.net/manual/en/function.chmod.php

there's a few examples that are handy.

HTH,
John




More information about the talk mailing list