I'm assuming you are running PHP on a Unix system, not Windows, which introduces problems I'm not interested in solving.
- Create a file, with whatever I want on how many lines I want.
Answer: Use the file functions in the manual. However,
1a. And set permissions (if needed) on a Unix server.
Answer: That's the harder part. The DIRECTORY has to be writable by the Web server process, so you will either have to be superuser and set up group and user IDs appropriately, or do it the insecure-but-works way: "chmod a+rwx ." while in the directory.
Now your Web server/PHP process can create and modify its own files.
- Have the script do something every x amount of time.
Answer: If by "x amount of time" you mean run a script periodically, read up on the chron utility
- Have something happen each time the value of something goes up a certain value.
Answer: Could you give an example? That's too vague to anwer.