Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4272356
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T07:34:00+00:00 2026-05-21T07:34:00+00:00

How can I convert the numbers in the first class in PHP into the

  • 0

How can I convert the numbers in the first class in PHP into the numbers in the second class, is there a built in function to convert the numbers? Also is my title ”
Convert Integer to hex values” even correct?

class Permission {
    const READ         = 1;
    const UPDATE       = 2;
    const DELETE       = 4;
    const COMMENT      = 8;
    const GRANT        = 16;
    const UNDELETE     = 32;
    const WHATEVER     = 64;
}

into this

class Permission {
    const READ     = 0x0001;
    const UPDATE   = 0x0002;
    const DELETE   = 0x0004;
    const COMMENT  = 0x0008;
    const GRANT    = 0x0010;
    const UNDELETE = 0x0020;
    const WHATEVER = 0x0040;
}

UPDATE

To elaborate a little more of what I am trying to do.
I currently use the first class with a bitmask class for settings,
somebody suggested to me to change to the format in the second class though.
However I did not know how they came up with the 0x0020 style numbers from the numbers in my 1st class.

I now see how to get the 20 from 32 but I do not know how or why they had added 0x00 in front of it to make 0x0020 to replace my original 32

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T07:34:01+00:00Added an answer on May 21, 2026 at 7:34 am

    I’m a little confused here… 0x01 = 1.
    0x020 = 32, etc.

    Are you looking for some of the string formatters like available in printf/sprintf? You can use the %x marker to output hex values.

    edit: Also, yes, your conversions are correct.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In a UNIX shell script, what can I use to convert decimal numbers into
we can convert character to an integer equivalent to the ASCII value of the
How i can convert to c# code files to html files?Is there any generation
Is there a tool out there which can convert SQL syntax to LINQ syntax?
I have a 2-dimensional array where I need to convert the first diagonal numbers
So I'm trying some code out to convert numbers into strings. However, I noticed
How i can convert number 20020415 to date 15.04.2002. I am working in Microsoft
You can convert a negative number to positive like this: int myInt = System.Math.Abs(-5);
How can I convert an Excel date (in a number format) to a proper
How can I convert a list of strings (each of which represents a number,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.