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? Link to comment https://forums.phpfreaks.com/topic/16435-easy-way-to-determine-how-the-variable-is-obtianed/ 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. Link to comment https://forums.phpfreaks.com/topic/16435-easy-way-to-determine-how-the-variable-is-obtianed/#findComment-68443 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.