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 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 } ?> 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 } ?> 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)){ // } 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 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. 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. 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? 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. 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. Link to comment https://forums.phpfreaks.com/topic/209748-value-equals-anything/#findComment-1094984 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.