我是新來的PHP,我想有一個條件語句,像這樣簡單的問題:php |在條件語句
if ($foo != 'Any') { $condition .= '$this_foo == $foo &&';}
if ($bar != 'Any') { $condition .= '$this_bar == $bar &&';}
if ($txt != 'Any') { $condition .= '$this_txt == $txt &&';}
$condition .= '$num1 > 0 && $num2 < 1000';
if (...[php would parse the $condition variable])
{
someoperations
}
什麼是正確的語法,if語句解析變量$條件?所以條件語句依賴於其他變量並防止長嵌套條件語句。
在此先感謝!
+1。很好地解釋了 – Ben 2011-04-28 01:34:55
感謝!它幫助了我。當我有名譽時,我會贊成這一點。 – iamebet 2011-04-28 16:03:35
我們走了。我昨天才加入這裏,所以我是新手。 =) – iamebet 2011-04-28 16:53:16