mirror of
https://github.com/smarty-php/smarty.git
synced 2025-11-03 13:51:36 +01:00
220 lines
7.1 KiB
XML
220 lines
7.1 KiB
XML
<?xml version="1.0" encoding="iso-8859-1"?>
|
||
<!-- $Revision$ -->
|
||
<sect1 id="language.function.if">
|
||
<title>if,elseif,else</title>
|
||
<para>
|
||
Los comandos if del Smarty tiene mucho de la flexibilidad del comando
|
||
if de php, con algunas adiciones para la herramienta de template.
|
||
Todo <emphasis>{if}</emphasis> debe tener su <emphasis>{/if}</emphasis>.
|
||
<emphasis>{else}</emphasis> y <emphasis>{elseif}</emphasis> tambien son
|
||
permitidos.
|
||
Toda las condicionales de PHP son reconcidas, tal como
|
||
<emphasis>||</emphasis>, <emphasis>or</emphasis>,
|
||
<emphasis>&&</emphasis>, <emphasis>and</emphasis>, etc.
|
||
</para>
|
||
|
||
<para>
|
||
La siguiente es una lista de calificadores reconocidos, los cuales
|
||
deberan estar separados los dos elementos por espacios.
|
||
Nota loas articulos pueden listarse [entre corchetes] es opcional.
|
||
Equivalentes al lugar donde se apliquen en PHP.
|
||
</para>
|
||
|
||
<informaltable frame="all">
|
||
<tgroup cols="4">
|
||
<colspec colname="qualifier" align="center" />
|
||
<colspec colname="alternates" align="center" />
|
||
<colspec colname="meaning" />
|
||
<colspec colname="example" />
|
||
<colspec colname="php" />
|
||
<thead>
|
||
<row>
|
||
<entry>Calificador</entry>
|
||
<entry>Alternativa</entry>
|
||
<entry>Ejemplo de Sintaxis</entry>
|
||
<entry>Significado</entry>
|
||
<entry>Equivalente en PHP</entry>
|
||
</row>
|
||
</thead>
|
||
<tbody>
|
||
<row>
|
||
<entry>==</entry>
|
||
<entry>eq</entry>
|
||
<entry>$a eq $b</entry>
|
||
<entry>Iguales</entry>
|
||
<entry>==</entry>
|
||
</row>
|
||
<row>
|
||
<entry>!=</entry>
|
||
<entry>ne, neq</entry>
|
||
<entry>$a neq $b</entry>
|
||
<entry>Diferentes</entry>
|
||
<entry>!=</entry>
|
||
</row>
|
||
<row>
|
||
<entry>></entry>
|
||
<entry>gt</entry>
|
||
<entry>$a gt $b</entry>
|
||
<entry>Mayor que</entry>
|
||
<entry>></entry>
|
||
</row>
|
||
<row>
|
||
<entry><</entry>
|
||
<entry>lt</entry>
|
||
<entry>$a lt $b</entry>
|
||
<entry>menor que</entry>
|
||
<entry><</entry>
|
||
</row>
|
||
<row>
|
||
<entry>>=</entry>
|
||
<entry>gte, ge</entry>
|
||
<entry>$a ge $b</entry>
|
||
<entry>mayor que o igual</entry>
|
||
<entry>>=</entry>
|
||
</row>
|
||
<row>
|
||
<entry><=</entry>
|
||
<entry>lte, le</entry>
|
||
<entry>$a le $b</entry>
|
||
<entry>menor que o igual</entry>
|
||
<entry><=</entry>
|
||
</row>
|
||
<row>
|
||
<entry>!</entry>
|
||
<entry>not</entry>
|
||
<entry>not $a</entry>
|
||
<entry>negaci<EFBFBD>n (unary)</entry>
|
||
<entry>!</entry>
|
||
</row>
|
||
<row>
|
||
<entry>%</entry>
|
||
<entry>mod</entry>
|
||
<entry>$a mod $b</entry>
|
||
<entry>modulo</entry>
|
||
<entry>%</entry>
|
||
</row>
|
||
<row>
|
||
<entry>is [not] div by</entry>
|
||
<entry></entry>
|
||
<entry>$a is not div by 4</entry>
|
||
<entry>divisible por</entry>
|
||
<entry>$a % $b == 0</entry>
|
||
</row>
|
||
<row>
|
||
<entry>is [not] even</entry>
|
||
<entry></entry>
|
||
<entry>$a is not even</entry>
|
||
<entry>[not] es numero par (unary)</entry>
|
||
<entry>$a % 2 == 0</entry>
|
||
</row>
|
||
<row>
|
||
<entry>is [not] even by</entry>
|
||
<entry></entry>
|
||
<entry>$a is not even by $b</entry>
|
||
<entry>agrupar niveles pares [not]</entry>
|
||
<entry>($a / $b) % 2 == 0</entry>
|
||
</row>
|
||
<row>
|
||
<entry>is [not] odd</entry>
|
||
<entry></entry>
|
||
<entry>$a is not odd</entry>
|
||
<entry>[not] el numero es impar (unary)</entry>
|
||
<entry>$a % 2 != 0</entry>
|
||
</row>
|
||
<row>
|
||
<entry>is [not] odd by</entry>
|
||
<entry></entry>
|
||
<entry>$a is not odd by $b</entry>
|
||
<entry>[not] agrupa los niveles impares</entry>
|
||
<entry>($a / $b) % 2 != 0</entry>
|
||
</row>
|
||
</tbody>
|
||
</tgroup>
|
||
</informaltable>
|
||
<example>
|
||
<title>sentencia if</title>
|
||
<programlisting>
|
||
{if $name eq "Fred"}
|
||
Welcome Sir.
|
||
{elseif $name eq "Wilma"}
|
||
Welcome Ma'am.
|
||
{else}
|
||
Welcome, whatever you are.
|
||
{/if}
|
||
|
||
{* Un ejemplo con "or" logico *}
|
||
{if $name eq "Fred" or $name eq "Wilma"}
|
||
...
|
||
{/if}
|
||
|
||
{* El mismo que arriba *}
|
||
{if $name == "Fred" || $name == "Wilma"}
|
||
...
|
||
{/if}
|
||
|
||
{* La siguiente sintaxis no funcionara, el calificador de condici<63>n
|
||
deben estar separados entre ellos por espacios *}
|
||
{if $name=="Fred" || $name=="Wilma"}
|
||
...
|
||
{/if}
|
||
|
||
|
||
{* los parentesis son permitidos *}
|
||
{if ( $amount < 0 or $amount > 1000 ) and $volume >= #minVolAmt#}
|
||
...
|
||
{/if}
|
||
|
||
{* Usted tambi<62>n puede colocar funciones de PHP *}
|
||
{if count($var) gt 0}
|
||
...
|
||
{/if}
|
||
|
||
{* checa si el valor es par o impar *}
|
||
{if $var is even}
|
||
...
|
||
{/if}
|
||
{if $var is odd}
|
||
...
|
||
{/if}
|
||
{if $var is not odd}
|
||
...
|
||
{/if}
|
||
|
||
{* checa si la variable var es divisible por 4 *}
|
||
{if $var is div by 4}
|
||
...
|
||
{/if}
|
||
|
||
{* Checa si la variable var es igual, agrupandola por dos. i.e.,
|
||
0=even, 1=even, 2=odd, 3=odd, 4=even, 5=even, etc. *}
|
||
{if $var is even by 2}
|
||
...
|
||
{/if}
|
||
|
||
{* 0=even, 1=even, 2=even, 3=odd, 4=odd, 5=odd, etc. *}
|
||
{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
|
||
-->
|