phaedo5 Posted July 18, 2008 Share Posted July 18, 2008 Ok, this sort of seems simple, but it's giving me difficulty. I have a statement like this: if(preg_match('/whatever/', gethostbyaddr($_SERVER['REMOTE_ADDR'])) { $variable = true; } if(!$variable) { then do something } Is this not acceptable code? It seems to work, sometimes. Every once in a while a domain of 'whatver.com' will slip through and trigger my if statement. It seems to work quite a bit though. So I'm confused. I just want to know if I'm doing something that is 'not best practice' or if I'm even completely wrong. Any help would be great. Sorry it's sort of newb material. Link to comment https://forums.phpfreaks.com/topic/115466-php-simple/ Share on other sites More sharing options...
JasonLewis Posted July 18, 2008 Share Posted July 18, 2008 Define $variable before hand. $variable = false; if(preg_match('/whatever/', gethostbyaddr($_SERVER['REMOTE_ADDR'])) { $variable = true; } if(!$variable) { then do something } Link to comment https://forums.phpfreaks.com/topic/115466-php-simple/#findComment-593576 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.