ernest Posted February 17, 2007 Share Posted February 17, 2007 hi i am trying to pass a conditional statement to a function, but unsuccessful with many attempts. Any comment or solution? Thanks for helping The following is a simplied sample of what i am trying to do: $group = set_group('$r > 1'); function set_group($query){ if ($query) { //does not have the effect of "if ( $r > 1)", using "if("$query")" does not work either!! $group = 1; } return $group; } Thanks a lot Link to comment https://forums.phpfreaks.com/topic/38969-passing-conditional-statement-to-function/ Share on other sites More sharing options...
sspoke Posted February 17, 2007 Share Posted February 17, 2007 what is $r ? is $r is a number greater than 1 it would make group = 1; if not it would return the prevous group if anything if (eval($query)) { //does not have the effect of "if ( $r > 1)", using "if("$query")" does not work either!! maybe? Link to comment https://forums.phpfreaks.com/topic/38969-passing-conditional-statement-to-function/#findComment-187545 Share on other sites More sharing options...
kenrbnsn Posted February 18, 2007 Share Posted February 18, 2007 What are you trying to accomplish? Explain that and we may be able to suggest an alternative method. Ken Link to comment https://forums.phpfreaks.com/topic/38969-passing-conditional-statement-to-function/#findComment-187644 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.