Leading zeros are a non-existent concept for integers, since they are mathematically insignificant. In decimal notation, the integer 0777 simply and exactly equal to 777 .
But if you are trying to convert "0777" to octal notation into its integer copy ( 511 as decimal) for use with chmod() , you can use octdec($input) . The function takes a string and spits out an integer, doing exactly what it says about the gesture.
Of course, be sure to check first, for example. using regex. You do not want to pass a global or invalid flag to chmod() and potentially publish your sensitive files and folders.
source share