The function may be nested. To do so, nest the inner #if function in its full form in place of the third parameter of the enclosing #if function. A depth of at least seven levels of nesting is possible, although that may depend on the wiki or a memory limit.
Example: {{#if: test string | value if test string is not empty | {{#if: test string | value if test string is not empty | value if test string is empty (or only white space) }} }}
See Help:Parser functions in templates for more examples of this parser function.
#ifeq
这个函数判断两个字符串是否相同。
{{#ifeq: string 1 | string 2 | value if identical | value if different }}
Warning:
Numerical comparisons with #ifeq and #switch are not equivalent to comparisons with #expr:
not equal → not equal
not equal → not equal
because PHP compares two numbers of type integer, whereas:
equal → equal
because MediaWiki converts literal numbers in expressions to type float, which, for large integers like these, involves rounding.
Warning:
Tags and parser functions inside parser tags (such as ) are temporarily replaced by a unique code. This affects comparisons:
{{#ifeq: <nowiki>foo | foo | equal | not equal}} → not equal
equal → not equal
equal → not equal
equal → equal
If the strings to be compared are given as equal calls to the same template containing such tags, then the condition is true, but in the case of two templates with identical content containing such tags it is false.
Warning:
Be careful when comparing against the current page title using the page name magic words. These magic words convert special characters into numeric HTML entities. This may result in misleading results. For example, if you are on a page titled "L'Aquila"...
not equal → not equal
To work around this, apply the magic word to both parameters: