title: Is it possible to define a local constant within a PHP function?
body: <p>It might be nice to be able to define a local constant within the scope of a function in PHP</p>
  
  <p>This way anyone reading the function would know that that definition is final within the function and doesn't affect any external code</p>
  
  <p>Something like this (Not valid syntax):</p>
  
  <pre><code>public function laughManiacally($count){
    const LAUGH = 'HA';
  
    for($i=0;$i&lt;$count;$i++){
      echo LAUGH;
    }
  };  
  </code></pre>
  
  <p>Or possibly (Again not valid):</p>
  
  <pre><code>...
  final $laugh = 'HA';
  ...
  </code></pre>
  
  <p>Is there anyway to do this? And if not why not?</p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>The way that JavaScript allows block level constant declaration is similar to the functionality I was searching for</p>
  
  <pre><code>function laughManiacally(count) {
    const LAUGH = 'Ha';
  
    for (let i = 0; i &lt; count; i++) {
      console.log(LAUGH);
    }
  }
  </code></pre>