Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Regular Coder
    Join Date
    Aug 2010
    Location
    Now Southern Oregon. I was born and had lived my life in Los Angeles until relocating last year (2010)
    Posts
    215
    Thanks
    52
    Thanked 1 Time in 1 Post

    converting string to octal number?

    I am developing an app that has a form for changing the access permissions of files.
    So, the user enters the octal value to change the permissions to. This value is
    set to the value of a hidden field. So the php processing script gets a string rep
    of the octal value ('0644' for instance). When calling chmod(), the second argument
    has to be a number.
    So, the question is how to convert the string to a number value. I thought there
    was a parseint type function in php but I can't find any.

    thanks for time and attention

  • #2
    Senior Coder
    Join Date
    Jan 2011
    Location
    Missouri
    Posts
    4,450
    Thanks
    23
    Thanked 631 Times in 630 Posts
    Not the droid your looking for, but wouldn't it be simpler for the user if you used full English words instead of coded numbers? Like "Read Only", or "Read and Over Write". I think it would be easier to interpret in the PHP code also.
    Evolution - The non-random survival of random variants.

    "If you leave hydrogen alone, for long enough, it begins to think about itself."

  • #3
    Regular Coder
    Join Date
    Aug 2010
    Location
    Now Southern Oregon. I was born and had lived my life in Los Angeles until relocating last year (2010)
    Posts
    215
    Thanks
    52
    Thanked 1 Time in 1 Post
    I am working on a Unix based system and am used to wrx type perms or octal/decimal perms such as 0644 (octal) or 644 (dec).
    Setting these requires dealing with the way Unix based systems store permissions.

    Anyhow, I did find the function settype()
    and am using it this way:
    Code:
    $_str = '0666';
    $_starttype = gettype($_str);
    settype($_str, "integer");
    $_newtype = gettype($_str);
    print $_starttype." : ".$_newtype;
    // script result: string : integer


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •