Do you have a question? Post it now! No Registration Necessary. Now with pictures!
- Posted on
- Pass octal value to function
January 23, 2005, 10:53 pm
rate this thread
I am trying to create a class to handle directory permissions but
passing the permission settings is going nowhere.
Octals seem to automatically get converted to decimal when sent and
when trying to convert back using decoct the 0 is dropped.
I have also tried sending as a string but chmod() does not accept
string input and I haven't been able to convert back to a number &
retain the leading 0.
echo "PASSED VAL:".$myvar;
// PASSED VAL:511
Re: Pass octal value to function
ok so what's wrong there? i guess if you'd pass the (decimal) 511 to chmod,
it'll interpret it just like it'd interpret a literal 0777.
echo "STRING:". '0'.(decoct($myvar)*1);
you first prepended the '0', making it a string, and then multiplied by 1,
turning it into an integer again.