Wayniac Posted August 4, 2010 Share Posted August 4, 2010 Hello all, Just a quick one here, I'm not sure what to put in the quotations of an if statement if I want to say if value equals ANYTHING. Thanks Quote Link to comment https://forums.phpfreaks.com/topic/209748-value-equals-anything/ Share on other sites More sharing options...
newbtophp Posted August 4, 2010 Share Posted August 4, 2010 <?php if ($value == "newbtophp") { //blah blah } ?> Quote Link to comment https://forums.phpfreaks.com/topic/209748-value-equals-anything/#findComment-1094957 Share on other sites More sharing options...
Wayniac Posted August 4, 2010 Author Share Posted August 4, 2010 I think I could reword it a little better. I'm trying to accomplish an action from an if statement that will work if anything from a space, to a letter, to a full fledge word is entered in the value spot within the "". Ex: <?php if ($fname == "ANYTHING") { // But I can't just put ANYTHING in that slot via server side, it would have to be typed. //blah blah } ?> Quote Link to comment https://forums.phpfreaks.com/topic/209748-value-equals-anything/#findComment-1094962 Share on other sites More sharing options...
onlyican Posted August 4, 2010 Share Posted August 4, 2010 So check that the variable is not blank if ($fname != ''){ // } //OR just check it is set if(isset($fname)){ // } Quote Link to comment https://forums.phpfreaks.com/topic/209748-value-equals-anything/#findComment-1094966 Share on other sites More sharing options...
Rifts Posted August 4, 2010 Share Posted August 4, 2010 I'm having this exact same problem I need a wildcard but I cant seem to find anything about php wildcards I need mine to find any file that ends in .txt so normally it would be like *.txt but that doesnt work Quote Link to comment https://forums.phpfreaks.com/topic/209748-value-equals-anything/#findComment-1094967 Share on other sites More sharing options...
Wayniac Posted August 4, 2010 Author Share Posted August 4, 2010 Thank you onlyican, that worked perfectly. Quote Link to comment https://forums.phpfreaks.com/topic/209748-value-equals-anything/#findComment-1094969 Share on other sites More sharing options...
Mchl Posted August 4, 2010 Share Posted August 4, 2010 rifts: look it preg_match Wayniac: empty might be a better choice. Quote Link to comment https://forums.phpfreaks.com/topic/209748-value-equals-anything/#findComment-1094975 Share on other sites More sharing options...
Wayniac Posted August 4, 2010 Author Share Posted August 4, 2010 Thanks for the tip, is there any advantage to why I would use empty()? Is the other depreciated? Quote Link to comment https://forums.phpfreaks.com/topic/209748-value-equals-anything/#findComment-1094977 Share on other sites More sharing options...
Mchl Posted August 4, 2010 Share Posted August 4, 2010 It will not raise a notice if the variable tested is not set at all. Quote Link to comment https://forums.phpfreaks.com/topic/209748-value-equals-anything/#findComment-1094979 Share on other sites More sharing options...
Wayniac Posted August 4, 2010 Author Share Posted August 4, 2010 Awesome, thank you. Quote Link to comment https://forums.phpfreaks.com/topic/209748-value-equals-anything/#findComment-1094984 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.