title: How to create const arrays of instances of a class, within that class?
body: <p>I'm creating my own PHP class. I want to have constant references within that class of instances of that class, like an enumeration.</p>
  
  <p>I keep getting 2 errors:
  1. Constants cannot be arrays
  2. parse error at line 11 (see below)</p>
  
  <p>What's wrong? Can I seriously not have a constant array? I'm from a Java background...</p>
  
  <p><strong>Here is my code:</strong></p>
  
  <pre><code>class Suit {
      const SUIT_NAMES = array("Club", "Diamond", "Heart", "Spade");
      const COLOURS = array("red", "black");
  
      const CLUB = new Suit("Club", "black");        // LINE 11
      const DIAMOND = new Suit("Diamond", "red");
      const HEART = new Suit("Heart", "red");
      const SPADE = new Suit("Spade", "black");
  
      var $colour = "";
      var $name = "";
  
      function __construct($name, $colour) {
          if (!in_array(self::SUIT_NAMES, $name)) {
              throw new Exception("Suit Exception: invalid suit name.");
          }
          if (!in_array(self::COLOURS, $colour)) {
              throw new Exception("Suit Exception: invalid colour.");
          }
          $this-&gt;name = $name;
          $this-&gt;colour = $colour;
      }
  }
  </code></pre>