Page is a not externally linkable
- Code, Content, and Presentation
-- PHP Server Side Scripting
---- Using a variable for an "if "condition


rover - 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"';

if($the_condition)

{

echo "$a is equal to yes";

}

else

{

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?


Thread source:: http://www.webmasterworld.com/php/11768.htm
Brought to you by WebmasterWorld: http://www.webmasterworld.com