title: Assigning a variable's value to a constant in PHP
body: <p>I have a config file that contains a constant array that is to be used globally throughout my script.</p>
  <pre><code>const ENV = [
          'project_name' =&gt; '*',
          'database' =&gt; [
              'db' =&gt; '*',
              'username' =&gt; '*',
              'password' =&gt; '*',
              'host' =&gt; 'localhost',
              'port' =&gt; '3306',
          ],
          'host' =&gt; $_SERVER['HTTP_HOST'],
          'ssl' =&gt; ($_SERVER[&quot;REQUEST_SCHEME&quot;] == 'https') ? true : false,
      ];
  </code></pre>
  <p>When executing the above, I get the following error:</p>
  <pre><code>Fatal error: Constant expression contains invalid operations in */config.php on line 3
  </code></pre>
  <p>The reason why I'm trying to have everything predefined in a constant is really not relevant at this stage as this decision was kind of out of my hands.</p>
  <p>Please note, I have other values as well that are to be calculated and dealt with before they can be assigned to the constant. Therefore, would love to get to know of a way to store a value (not address to the variable) in the constant array.</p>