Cep Posted August 3, 2006 Share Posted August 3, 2006 Hello,I am setting up a system were I want to obtain the variable $action value from either a session, get or post action.At the moment I use a very long if statement like this,[code]if (isset($_POST['action'])) { $action = $_POST['action']; } else { if (isset($_GET['action'])) { $action = $_GET['action']; } else { if (isset($_SESSION['action'])) { $action = $_SESSION['action']; } else { $action = ""; } }}[/code]Is there a tidier way to do this? Quote Link to comment Share on other sites More sharing options...
Orio Posted August 3, 2006 Share Posted August 3, 2006 You can use "elseif"-[code]<?phpif (isset($_POST['action'])) { $action = $_POST['action'];} elseif(isset($_GET['action'])) {$action = $_GET['action'];} elseif(isset($_SESSION['action'])) {$action = $_SESSION['action'];else{$action="";}?>[/code]Orio. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.