I have been programming for a number of years now and in PHP for about 4 of those years. I have always wondered what is the best approach when it comes your program deciding what action to take based on a user action.Let me narrow this down a little bit. I have a small custom built CMS running, one of the pages allows an admin to view and edit user account details such as name, generate a new password, change payment dates and so on. I have a number of different actions here:View all usersView single user View users (search string)Edit user Edit SubscriptionEdit NameEtcDelete UserBlacklistFor all of these actions i provide a let with GET data, for exampele:<a href=users.php?action=show_user&uid=12>User A</a>The links for the other things like editing a user would be action=edit_subscription for example.When My page loads i usually use an IF ELSE statement to check if an action is present before doing on.if($_GET['action'] == show_user){}else if($_GET['action'] == edit_subscription){}Once the program matches the action it checks for other data such as UID and then sends that data off into a classes to be processed. Sometimes this can feel a little long winded and can be a little difficult to debug.I don't know if this is the best way of doing it, i was recently looking into using a switch statement and wondered if this would be better but I'm not sure if it.So if there a better way for me to achieve this selection process, maybe some sort of pattern that can be used? Once last point is that i am trying to keep everything in once file (apart from classes) so the HTML and the PHP for matching actions are all in the same .php file, also not 100% sure if this is best practice as well.Thanks for your time.
Selecting between multiple actions in PHP
php