fopen – write to file with php through a form

I'm working on creating and modifying a file from php.
What I want is, through a form, to write three numbers in a file. Then I need to show on screen the result of adding those numbers that are in the file.


  
    
    
  
  







How would the php code be? using fopen, fwrite?