title: php not working on localhost but on web server?
body: <p>I'm a beginner of php and am experiencing a weird problem of php code not working on localhost (open the index.php with Chrome on disk D) but working on web server. Here is my index.php. I searched for solutions but do not find one. </p>
  
  <pre><code>&lt;!DOCTYPE html&gt;  
  &lt;html lang="en"&gt;  
  &lt;head&gt;
  &lt;meta charset="utf-8" /&gt;  
  &lt;link rel="stylesheet" type="text/css" href="style.css"&gt;
  &lt;title&gt;Hello World!&lt;/title&gt;  
  &lt;/head&gt;  
  &lt;body&gt;
  &lt;h1&gt;Hello World!&lt;/h1&gt;
  &lt;p&gt;&lt;?php echo "Success"; ?&gt;&lt;/p&gt;
  &lt;p&gt;Welcome! This is my personal webpage. &lt;/p&gt;
  &lt;p style="color:red"&gt;This is a red font. &lt;/p&gt;
  &lt;a href="subpage1.html"&gt;&lt;p&gt;Link&lt;/p&gt;&lt;/a&gt;
  &lt;p&gt;&lt;?php 
      $file = 'people.txt';
      // Open the file to get existing content
      $current = file_get_contents($file);
      // Append a new person to the file
      $current .= "John Smith\n";
      // Write the contents back to the file
      print file_put_contents($file, $current);
      echo "finished";
       ?&gt;&lt;/p&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>The <code>style.css</code> is just some basic formatting of <code>&lt;h1&gt;</code> and <code>&lt;p&gt;</code>. </p>
  
  <p>In addition, there is a <code>person.txt</code> file on the same directory with <code>index.php</code>.</p>
  
  <p>So on localhost, Chrome browser does NOT print "Success", update my <code>person.txt</code>, or print "finished". However, when I upload the <code>index.php</code>, <code>person.txt</code>, and <code>style.css</code> to my web server using ftp, all the php codes are working. Can anyone help me on this? </p>
  
  <p>P.S. The website is <a href="http://yilunzhou.site50.net" rel="nofollow">here</a>. </p>