horseatingweeds Posted July 31, 2007 Share Posted July 31, 2007 I have a function for converting state codes into names. However, some state codes I don't know of and the way I have the input allows people to put in a state. So, I was wondering if a variable, in this case a state code, is inputed into the function that turns up undefined I can have a statement to handle it and basically have it ignored and printed as the person typed it. Quote Link to comment https://forums.phpfreaks.com/topic/62611-is-there-a-way-to-make-an-if-statment-for-something-undefined/ Share on other sites More sharing options...
clearstatcache Posted July 31, 2007 Share Posted July 31, 2007 pls show ur code.... Quote Link to comment https://forums.phpfreaks.com/topic/62611-is-there-a-way-to-make-an-if-statment-for-something-undefined/#findComment-311663 Share on other sites More sharing options...
btherl Posted July 31, 2007 Share Posted July 31, 2007 Something like this? $name = state_to_name($state); if ($name === null) { $name = $state; } Assuming your state_to_name() returns null if no match is found Quote Link to comment https://forums.phpfreaks.com/topic/62611-is-there-a-way-to-make-an-if-statment-for-something-undefined/#findComment-311704 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.