| Welcome to WebmasterWorld Guest from 184.108.40.206 |
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
|Become a Pro Member|
|Using a variable for an "if "condition|
is this possible?
| 10:03 pm on Feb 16, 2006 (gmt 0)|
Is there any way to have a condition for an if statement be evaluated according to its contents and not whether the variable is defined or not? In other words:
$a = 'no';
$the_condition = '$a == "yes"';
echo "$a is equal to yes";
echo "$a is not equal to yes";
This will always evaluate as true and print yes because $the_condition variable is defined.
Is there any syntax so that I can have it actually evaluate the condition within the variable and whether that is true or not?
| 10:32 pm on Feb 16, 2006 (gmt 0)|
Sounds like a job for switch [php.net].
| 10:50 pm on Feb 16, 2006 (gmt 0)|
A blast from the past ...
Variable condition statements [webmasterworld.com]
| 2:27 am on Feb 17, 2006 (gmt 0)|
Thanks very much, those posts helped me solve it using the eval function.
All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved