demo7up Posted September 7, 2012 Share Posted September 7, 2012 I need help making something like this. so for example if ($number == NULL) { echo 'there is a $number'; } else { echo 'There is no value'; } thanks in advance Link to comment https://forums.phpfreaks.com/topic/268120-hide-sting-if-variable-is-null/ Share on other sites More sharing options...
Jessica Posted September 7, 2012 Share Posted September 7, 2012 And the problem is??? Besides the fact that you have a variable inside single quotes? Link to comment https://forums.phpfreaks.com/topic/268120-hide-sting-if-variable-is-null/#findComment-1376036 Share on other sites More sharing options...
demo7up Posted September 7, 2012 Author Share Posted September 7, 2012 i totally just came up with that in my head had no idea it was correct.. besides the single quotes.. also would this be better? if (isset($number)) { echo "Variable is set"; } else { echo "its not set"; } Link to comment https://forums.phpfreaks.com/topic/268120-hide-sting-if-variable-is-null/#findComment-1376040 Share on other sites More sharing options...
Jessica Posted September 7, 2012 Share Posted September 7, 2012 I usually use isset personally, I don't know that one version is better than the other. If you "come up" with code, rather than asking other people if it's usable you could, you know, try to use it? Link to comment https://forums.phpfreaks.com/topic/268120-hide-sting-if-variable-is-null/#findComment-1376042 Share on other sites More sharing options...
spiderwell Posted September 7, 2012 Share Posted September 7, 2012 isset() is to check if the variable has been set, regardless of its value, the first post will tell you if the variable has a value of null. Link to comment https://forums.phpfreaks.com/topic/268120-hide-sting-if-variable-is-null/#findComment-1376083 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.