ManicMax Posted May 4, 2007 Share Posted May 4, 2007 Currently I cant get a function to work within an if statement what syntax does it need to work. At the moment I have to put the function into a variable then compare it in the if statement. Any help appriciated Quote Link to comment https://forums.phpfreaks.com/topic/50067-using-functions-in-if-statements/ Share on other sites More sharing options...
pocobueno1388 Posted May 4, 2007 Share Posted May 4, 2007 Code would be nice =] Quote Link to comment https://forums.phpfreaks.com/topic/50067-using-functions-in-if-statements/#findComment-245735 Share on other sites More sharing options...
Barand Posted May 4, 2007 Share Posted May 4, 2007 Example <?php function validDay ($d) { /** * assumes any value between 1-31 is valid */ return ($d >=1) && ($d <= 31); } $day = 12; if (validDay($day)) { echo "OK"; } else { echo "Invalid"; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/50067-using-functions-in-if-statements/#findComment-245739 Share on other sites More sharing options...
neel_basu Posted May 5, 2007 Share Posted May 5, 2007 You should post some codes First. Quote Link to comment https://forums.phpfreaks.com/topic/50067-using-functions-in-if-statements/#findComment-245983 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.