Files
smarty/docs/ru/designers/language-builtin-functions/language-function-if.xml
tony2001 64e51b0e1e multiple ws fixes
added EN-Revision tags everywhere
2004-07-19 13:11:36 +00:00

109 lines
2.4 KiB
XML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?xml version="1.0" encoding="windows-1251"?>
<!-- $Revision$ -->
<!-- EN-Revision: 1.1 Maintainer: tony2001 Status: ready -->
<sect1 id="language.function.if">
<title>if,elseif,else</title>
<para>
Конструкция if в Smarty такая же гибкая, как и аналогичная
конструкциия в php, только с несколько расширенными
возможностями.
Каждый тэг <emphasis>if</emphasis> должен иметь пару
<emphasis>/if</emphasis>. <emphasis>else</emphasis> и
<emphasis>elseif</emphasis> так же допустимы. "eq", "ne",
"neq", "gt", "lt", "lte", "le", "gte" "ge", "is even",
"is odd", "is not even", "is not odd", "not", "mod",
"div by", "even by", "odd by", "==", "!=", "&gt;", "&lt;", "&lt;=",
">=" -- допустимые квалификаторы условий. Они должны быть
отделены от окружающих елементов пробелами.
</para>
<example>
<title>Конструкция if</title>
<programlisting>
<![CDATA[
{if $name eq "Fred"}
Welcome Sir.
{elseif $name eq "Wilma"}
Welcome Ma'am.
{else}
Welcome, whatever you are.
{/if}
{* пример с логикой ИЛИ ("or") *}
{if $name eq "Fred" or $name eq "Wilma"}
...
{/if}
{* аналогичен предыдущему *}
{if $name == "Fred" || $name == "Wilma"}
...
{/if}
{* следующий синтаксис не будет работать. квалификаторы условий должны
быть отделены от окружающих элементов пробелами *}
{if $name=="Fred" || $name=="Wilma"}
...
{/if}
{* допускаются скобки *}
{if ( $amount < 0 or $amount > 1000 ) and $volume >= #minVolAmt#}
...
{/if}
{* можно также вызывать встроенные функции php *}
{if count($var) gt 0}
...
{/if}
{* проверка значения на четность *}
{if $var is even}
...
{/if}
{if $var is odd}
...
{/if}
{if $var is not odd}
...
{/if}
{* проверка на делимость на 4 *}
{if $var is div by 4}
...
{/if}
{* проверка на "четность" групируя по 2. т.е.,
0=четно, 1=четно, 2=нечетно, 3=нечетно, 4=четно, 5=четно, и т.д. *}
{if $var is even by 2}
...
{/if}
{* 0=четно, 1=четно, 2=четно, 3=нечетно, 4=нечетно, 5=нечетно, и т.д. *}
{if $var is even by 3}
...
{/if}
]]>
</programlisting>
</example>
</sect1>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"../../../../manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->