PHP File Input / OutPut


Say you have a game or app that uses several different functions in a PHP file, using differen POST requests.

For example to login, update account details on database, to update the highscores database.

Is it better to have different PHP files for each request type?

For example instead of myapp.php have
login.php just for login requests
profiles.php for updating user account
highscores.php for updating or retrieving data from highscore db

If you have 3 or more different php files will this decrease the 'workload' (like I/O, bandwith retrictions) and increase efficiency compared to having 1 PHP file that handles ALL backend stuff?


No need to micro-optimize. The only thing you need to worry about is if you're using a free webhost who has some kind of arcane restriction (i.e. only 100 total files allowed or something). The bandwidth and other factors are simply not going to be affected significantly by this. Personally, I like to have one file act as an "entry-point" to all of the functionality, and then if I need a bunch of functionality, that one file will internally import other code. But that's me. Doesn't mean it's the only right way to do things.