title: How to change variable value in another php file
body: <p>Basically, the file.php has variable name $email whose value I have to change. This is how far I have done it and it doesn't seem to work:</p>
  
  <pre><code>function updateFile($email) {
  
  $file = 'file.php';
  $content = file_get_contents($file, NULL);
  $varname = '$email';
  $newvalue = $email;
  $content = preg_replace('/('. preg_quote($varname) .'=")[^"]+(")/', 
  $varname."=\"".$newvalue."\"", $content);
  file_put_contents($file, $content);
  
  }
  
  updateFile("test@gmail.com");
  </code></pre>