0

How do I make my own function to receive a possible array of "constant" as flag?

generateSomething($someInteger, WITH_ONE | WITH_TWO);

And in function definition it would be something like...

myFunction(???) {
  if (isset(MODE_ONE)) {
    // do something
  }

  if (isset(MODE_TWO)) {
    // do something
  }
{
Gab
  • 1
  • 3
  • Those flags are usually defined as values that have a certain bit set in their binary representation (so in decimal 1, 2, 4, 8, …) – that makes it possible to see if a certain flag was passed by using simple bitwise operators. – CBroe May 02 '14 at 00:14
  • What is the best practice of doing? Define own constant in my own function definition file and require it? – Gab May 02 '14 at 00:58
  • Found what I want in (http://stackoverflow.com/questions/13811922/what-does-using-a-single-pipe-in-a-function-argument-do). Thanks for telling me that it has something to do with bitwise operators. – Gab May 02 '14 at 01:06

0 Answers0