theredking Posted September 5, 2007 Share Posted September 5, 2007 Hi all, I'm happily plodding along... but! I would like to pass the results of an if statement to a var if possible. Sort of like how the "foreach" statement works. How do i do this?? Thank you in anticipation. Quote Link to comment https://forums.phpfreaks.com/topic/68144-solved-pass-the-results-of-an-if-statement-to-a-var/ Share on other sites More sharing options...
lemmin Posted September 5, 2007 Share Posted September 5, 2007 The "results" of an if statement is either true or false, which is indicated by whether it executes or not. Do you mean that you want to test a functions results as true or false, then use it in the statement? Have you tried something like: if ($var = function()) echo $var; ? Quote Link to comment https://forums.phpfreaks.com/topic/68144-solved-pass-the-results-of-an-if-statement-to-a-var/#findComment-342519 Share on other sites More sharing options...
theredking Posted September 5, 2007 Author Share Posted September 5, 2007 I answered my own question.... if ($var1 =="1") $var2 = "1 is correct."; else $var2 = "Do something else..."; echo $var2 Edit: Thanks for your time lemmin Quote Link to comment https://forums.phpfreaks.com/topic/68144-solved-pass-the-results-of-an-if-statement-to-a-var/#findComment-342521 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.