wemustdesign Posted April 9, 2009 Share Posted April 9, 2009 I know how to check if a variable has been set but how can I check if a value exists for the variable. I know how to check if it is NULL but how do I check if the variable has a value? Quote Link to comment https://forums.phpfreaks.com/topic/153341-check-if-value-exists/ Share on other sites More sharing options...
Maq Posted April 9, 2009 Share Posted April 9, 2009 isset() Quote Link to comment https://forums.phpfreaks.com/topic/153341-check-if-value-exists/#findComment-805618 Share on other sites More sharing options...
wemustdesign Posted April 9, 2009 Author Share Posted April 9, 2009 But I have already declared the variable: $x= $_GET['uk']; so if I use (isset($x)) it come back that a value has been set even though no variable has been passed by the query string Quote Link to comment https://forums.phpfreaks.com/topic/153341-check-if-value-exists/#findComment-805622 Share on other sites More sharing options...
Maq Posted April 9, 2009 Share Posted April 9, 2009 That will return true because $x has been set to something even if it's empty or null. If you want to check if the value of $x is empty then use: empty Quote Link to comment https://forums.phpfreaks.com/topic/153341-check-if-value-exists/#findComment-805626 Share on other sites More sharing options...
gffg4574fghsDSGDGKJYM Posted April 9, 2009 Share Posted April 9, 2009 Put the $_GET inside isset <?php if (isset($_GET['uk'])) { $x = $_GET['uk']; } else { $x = "default value"; } ?> is that what you are looking for ? Quote Link to comment https://forums.phpfreaks.com/topic/153341-check-if-value-exists/#findComment-805630 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.