title: PHP change .php file using PHP
body: <p>I'm trying to change some values from .PHP file using PHP.</p>
  
  <p>Here is my <code>config.php</code> file</p>
  
  <pre><code>class Config {
  
      const name = "Jorge Scâus"
      const domain = 'domain.com';
      const year = '2019';
      const version = 175b.89;
  
  }
  </code></pre>
  
  <p>and here is my <code>editor.php</code> file:</p>
  
  <pre><code>$fl='config.php'; 
  $tmp = fopen($fl, "r");
  $content=fread($tmp,filesize($fl));
  fclose($tmp);
  
  $content = preg_replace('/\const year=\'(.*?)\';/', 'const year=\'2050\';', $content);
  
  $tmp =fopen($fl, "w");
  fwrite($tmp, $content);
  fclose($tmp);
  </code></pre>
  
  <p>I'm executing this code to change <code>const year</code> but nothing is changed! And there are no errors. What I'm doing wrong?</p>
  
  <p>Can you help me?
  Thank you.</p>