title: How to check if a variable is a Magic Constant?
body: <p>I don't find any way online or scratching through the PHP docs to do this.</p>
  
  <p>Is there a friendly or light way check if a variable is a <a href="http://php.net/manual/en/language.constants.predefined.php" rel="nofollow noreferrer">Magic Constant</a> like <code>__FILE__</code> or <code>__DIR__</code>? Similar to <a href="http://php.net/manual/en/function.is-callable.php" rel="nofollow noreferrer"><code>is_callable()</code></a>?</p>
  
  <p>I want to check against the <code>$var</code> passed and run some if/else conditions on it. </p>
  
  <p>Small example. </p>
  
  <pre><code>function test($var) {
  
      if ($var == 'string_value') {
  
          // Do this...
  
      }
  
      elseif (is_magic_constant($var)) {
  
          // Do this...
  
      }
  
      else {
  
          // Do this...
  
      }
  
  }
  
  test('string_value');
  test(__FILE__);
  </code></pre>