[PHP] Re: Can someone explain this please...

2002-08-15 Thread Bogdan Stancescu

Hummm, sorry, you're right, you're converting it do a "fake" octal via 
strings, I was wrong in my first paragraph. In any case, if it helps, on 
my comp it really does evaluate true.

Bogdan

Gandalf wrote:
> 
> 
> Hello!
> 
> I am doing this
> 
> $newpath = "./uploads/newdir/";
> if (!is_dir($newpath)) mkdir($newpath, 0666);
> $decperms = fileperms($newpath);
> $octalperms = sprintf("%o",$decperms);
> $perms=(substr($octalperms,2));
> echo $perms;
> 
> if ($perms != 777)
> {
> rmdir ($newpath);
> }
> 
> This will not delete the dir created with $newpath.
> It will only work if i change this
> 
> if ($perms != 777)
> into this
> if ($perms != '777' ) // Please note the single quotes around 777
> 
> Could someone tell me why it behaves like this?
> Cause if for example i do this
> 
> $foo = 1;
> if ($foo == 1) //will evaluate as true, so why not with the above?
> 
> Thanks a lot in advance for your time and help!
> 
> Best regards from Vienna,
> Jürgen
> 
> 
> 



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP] Re: Can someone explain this please...

2002-08-15 Thread Bogdan Stancescu

Hi!

I don't know why it doesn't because it really should ALWAYS evaluate 
true with your code, regardless of absolutely anything.

The reason is that the quoteless 777 you're comparing to is in decimal 
and it would defy math if you were ever able to get $perms==777. Anyway, 
it does evaluate true on my computer and does delete that dir.

You might want to try this:



Please be aware though that in typical conditions your permissions are 
masked, therefore you're not going to be able to create directories with 
0777 permissions via PHP without tweaking your PHP config.

HTH

Bogdan

Gandalf wrote:
> 
> 
> Hello!
> 
> I am doing this
> 
> $newpath = "./uploads/newdir/";
> if (!is_dir($newpath)) mkdir($newpath, 0666);
> $decperms = fileperms($newpath);
> $octalperms = sprintf("%o",$decperms);
> $perms=(substr($octalperms,2));
> echo $perms;
> 
> if ($perms != 777)
> {
> rmdir ($newpath);
> }
> 
> This will not delete the dir created with $newpath.
> It will only work if i change this
> 
> if ($perms != 777)
> into this
> if ($perms != '777' ) // Please note the single quotes around 777
> 
> Could someone tell me why it behaves like this?
> Cause if for example i do this
> 
> $foo = 1;
> if ($foo == 1) //will evaluate as true, so why not with the above?
> 
> Thanks a lot in advance for your time and help!
> 
> Best regards from Vienna,
> Jürgen
> 
> 
> 



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php