I have a general question about servers and files. It is possible in PHP to write out a file on the server, say, temp.php created by index.php. If this file has a fixed name, is this file accessible to every user of this site (which I don't want)? That is, is there only one copy at a time, or does every user (potentially hundreds at any given moment) somehow get their own copy?
I'm toying with the idea of having a PHP file (both HTML and PHP code) written out by index.php and then run (PHP header Location call). If the name of the file is not somehow unique, I fear I will run into problems with conflicts and race conditions. For example, if User A runs index.php to create temp.php, and a fraction of a second later, User B does the same (with slightly different content), might User A end up running User B's temp.php? Or, User A ends up trying to run an empty temp.php, because User B has just truncated temp.php in preparation for rewriting it. Can these things really happen, or am I overthinking it? I saw this very thing happen with Simple Machines Forum's configuration file when it was rewritten on the fly to record error events (yes, a very stupid design).
I suppose there's an alternative in that I can make a really ugly and complex index.php that ends up outputting only HTML (directly to the browser), without an intermediate PHP file. I guess this is sort of what a Content Management System like WordPress, Joomla, or Drupal does, but I really don't want to reinvent such a thing. Do osC's "hooks" work anything like this? This is something that is probably too much to put in a cookie or HTML local storage or in a database. It would be so nice to just write a PHP file and be able to run it (letting the server take care of code execution), if I can be sure that multiple users won't step on each other.
PHP gives the ability to write a file, and PHP is normally run on a server (with multiple active users at any one time). Can it really keep everyone's same-named files separate, or was it never intended to? I can't think of how it would do that. I could also try to give each new file a unique name (or unique directory with mkdir), but that would be ugly looking, and there is the danger of cluttering up the server with thousands of no-longer-needed temporary files, which would need to be cleaned out on a regular basis (once run). Someone must have solved this problem before! Suggestions or hints welcome.