title: Using a const in const
body: <p>I have a bit of php which has to generate a script. Part of it is pretty much static, but the data is generated on the fly. I had a similar problem in another language a time back and solved it using constant substitutes.</p>
  
  <p>What I'm trying to do:</p>
  
  <pre><code>interface IConstants {
      const SUBSTITUTE = '!substitute';
      const FULL_STRING = 'var data = "' . self::SUBSTITUTE . '";';
  }
  
  class Util {
      public static function replace($haystack, $needle, $replace) {
      // implementation
      }
  }
  
  class SampleClass {
      public function getScript() {
          $someData = $this-&gt;getData();
          return Util::replace(IConstants::FULL_STRING, IConstants::SUBSTITUTE, $someData);
      }
  
      public function getData() {
          // generate $someData
          return $someData;
      }
  }
  </code></pre>
  
  <p>Is this design accepted for PHP? If yes, how would I implement it, and if no, what would be a suitable alternative?</p>