Gyohdon Posted November 25, 2010 Share Posted November 25, 2010 I currently have a page which redirects to itself, with variables stored in the URL, using the GET method to retrieve them and change the page.However when making this, I found that when no variables were given, the page gave error messages. (Because of this I added '?category=x&order=x' at the end).My question is: How do I check if a GET-variable doesn't exist? Link to comment Share on other sites More sharing options...
birbal Posted November 25, 2010 Share Posted November 25, 2010 you have to use isset if(!isset($_GET['category'])){//get category is not set}else{//get category is set} you may add more condition depending your need Link to comment Share on other sites More sharing options...
jeffman Posted November 25, 2010 Share Posted November 25, 2010 Either of these, depending on your needs:if (isset($_GET['category']) ) {// do something}if (!empty($_GET['category']) ) {// do something}Of course, you can change the logic and do something if the query is not set or is empty. Link to comment Share on other sites More sharing options...
birbal Posted November 25, 2010 Share Posted November 25, 2010 How do I check if a GET-variable doesn't exist?i want to add one more thing there is some diffrenece beetwen empty[/empty] and isset.so you have to be cautious for some purpose.$var=0; // or var="";empty($var) will evaulate FALSEwhere as isset($var) will evaulate true Link to comment Share on other sites More sharing options...
Gyohdon Posted November 25, 2010 Author Share Posted November 25, 2010 i want to add one more thing there is some diffrenece beetwen empty[/empty] and isset.so you have to be cautious for some purpose.$var=0; // or var="";empty($var) will evaulate FALSEwhere as isset($var) will evaulate true Thanks, it works now. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.