Why not, in your case, just compare two numerical values?
Like this:
if (0777 != $permissions) { //do something }
However, to convert the value to a string containing the octal representation of the number, you can use sprintf and the o specifier.
For example, the following part of the code:
var_dump(sprintf("%04o", 0777));
You'll get:
string(4) "0777"
Pascal martin
source share