Smarty, smarty format, smarty Integer, Smarty float, smarty Various conversion modes, Smarty date conversion, etc. (RPM)

Source: Internet
Author: User
Tags float number

<?
Require ("setup.php");
Define (' PageTitle ', ' pagtitle ');
function Insert_top ($lid, $sid)
{
echo "Insert Function";
}
$smarty =new smartyrebuild ();
$smarty->assign (' name ', 'Linux‘);
$smarty->assign (' title ', ' online has to have a kind wrong to want ');
$smarty->assign (' English_word ', ' My name x4 is Linux ');
$smarty->assign (' money ', ' 344.2223 ');
$smarty->assign (' member ', Array (' fax ' = ' 010-95888484 ', ' email ' = ' [email protected] ',
' Phone ' =>array (' home ' = ' 8488484 ', ' mobil ' = ' 5325325325353 '));
$tempMember =array ();
$tempMember [' member ']= ' dsgads ';
$tempMember ["Phone"] ["Home"]= "444333";
$contacts =array ();
$contacts [] "Fax"]= "435454";
$contacts [] "Phone"]= "223523523";
$contacts [] "Fax"]= "42532532";
$contacts [] "Phone"]= "7888888";
$contacts 2=array (' fax ' = ' 32523 ', ' phone ' = ' 325132532 '), Array (' fax ' = ' 2313532 ', ' phone ' = ') ' 325325132523 '));
$contacts 3=array ();
$contacts 3[0]= "23523";
$contacts 4=array ();
$contacts 4[0][0]= "23523";
$contacts 4[0][1]= "23523";
$contacts 3[1]= "23523";
$contacts 4[1][0]= "23523";
$contacts 4[1][1]= "23523";
$contacts 3[2]= "23523";
$contacts 4[2][0]= "23523";
$contacts 4[2][1]= "23523";
$contacts 3[3]= "23523";
$contacts 4[3][0]= "23523";
$contacts 4[3][1]= "23523";
$smarty->assign (' contacts ', $contacts);
$smarty->assign (' contacts2 ', $contacts 2);
$smarty->assign (' Contacts3 ', $contacts 3);
$smarty->assign (' Contacts4 ', $contacts 4);
$smarty->assign (' Tempmember ', $tempMember);
$smarty->display (' Index.tpl ');
?>



Smarty Code:



{config_load file= ' config.conf '}
<! DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 transitional//en" >
<HTML>
<HEAD>
<title>smarty Learning </TITLE>
<meta name= "Generator" content= "EditPlus" >
<meta name= "Author" content= "" >
<meta name= "Keywords" content= "" >
<meta name= "Description" content= "" >
</HEAD>

<BODY>
{Capture Name=banner} {* Comment out the middle display *}
{include file= "BANNER.TPL"}
{/capture}
{include file= "BANNER.TPL" title= "Smarty Learning"}
{$smarty .get.page}<br/>
{$smarty .post.page}<br/>
{$smarty .cookies.name}<br/>
{$smarty .server.server_name}<br/>
{$smarty .env.path}<br/>
{$smarty .session.id}<br/>
{$smarty .request.username}<br/>
{$smarty. Now|date_format: '%y-%m-%d%h:%m:%s '}<br/>
{$smarty. Const.pagetitle} {* Constant *}<br/>
Hello {$name}{* variable *}<br/>
{Html_select_date display_days=yes}<br/>
{$member .fax}<br/>
{$member .phone.home}<br/>
{$tempmember .member}<br/>
{$tempmember. Phone.home} {* Multidimensional array *}<br/>
{#error_message #} {* Config file properties *}<br/>
{$name |lower} {*smarty string function *}<br/>
{$name |upper} {*smarty string function *}<br/>
{' Now ' |date_format: '%y-%m-%d '} {*smarty Date function *}<br/>
{$title |truncate:11: "..."} {* Truncated string extra long plus ...*}<br/>
{mailto|lower address= "mailto:[email protected]%22%7d%7b*mailto Mail *}<br/>
Mailto:%7b$tempmember%[email the sum of the protected]}{* data *}<br/>
{$english _word|capitalize} {* First Capital letter *}<br/>
{$english _word|capitalize:true} {* Capitalize the first letter of each word *}<br/>
{$title |count_characters:true} {* String length plus true spaces, no space is calculated without true *}<br/>
{$title |cat: ' Add character after string '} {* Stitching string *}<br/>
{$title |count_words} {* Count the number of characters *}<br/>
{$title 2|default: "Dsgadsgds"}; {* Output default value if the variable does not exist *}<br/>
{$english _word|escape:html} {* Converts HTML in a string to HTML encoding *}<br/>
{$english _word|escape:htmlall} {* Converts HTML in a string to HTML encoding *}<br/>
{$english _word|escape:url} {* Converts HTML in a string to URL encoding *}<br/>
{$english _word|escape:quotes} {* Converts HTML in a string to HTML encoding *}<br/>
{$title |indent:100} {* Indent the specified width *}<br/>
{$title |regex_replace: "/To/": "Love"} {* Regular expression substitution character *}<br/>
{$title |replace: "Want": "Love"} {*replace substitution character *}<br/>
{$english _word|spacify: "| |"} {* Delimited string *}<br/>
{$money |string_format: "%.2f"} {* Formatted number is float number *}<br/>
{$money |string_format: "%d"} {* formatted number is int number *}<br/>
{$english _word|strip: ""} {* Replace space *}<br/>
{$english _word|strip_tags:false} {* Replace label *}<br/>
{$english _word|truncate:10: "..."} {* Intercept a specified length character, the default intercept 80 character length *}<br/>
{$english _word|wordwrap:10} {* How long the string wraps, the default line wrap length is 80*}<br/>
{$english _word|upper|spacify|truncate:30: "..."} {*smarty supports a combination of multiple functions, which are capitalized first and then delimited and then truncated to a specified length *}<br/>
{foreach Name=outer item=contact from= $contacts} {*foreach Loop array *}
{foreach Key=key item=item from= $contact}
{$key}:{$item}<br/>
{/foreach}
{/foreach}
{foreach Name=outer item=contact2 from= $contacts 2}
{foreach Key=key Item=item from= $contact 2}
{$key}:{$item}<br/>
{/foreach}
{/foreach}
{include_php file= "function.php"} {* Contains the specified PHP file *}
{Insert Name= "top" lid= "Toplid" sid= "Topsid"} {* Call insert_top PHP function, function parameter is lid and Sid's value *}
{if 1 eq 1} {* Conditional judgment statement *}
1=1
{ElseIf 1 NE 1}
1!=1
{ElseIf 1 GT 1}
1>1
{ElseIf 1 lt 1}
1<1
{ElseIf 1 GTE 1}
1>=1
{ElseIf 1 LTE 1}
1<=1
{ElseIf not 1 eq 1}
Not 1=1
{elseif (1 mod 1) EQ 1}
<font color= "Red" >1%1=1</font>
{Else}
You're a really bad character.
{/if}
{ldelim}function Insert_top {Rdelim} is insert_top {* Output brackets *}
{literal} {* Add a piece of HTML, script code, etc. *}
<script language= "javascript" type= "Text/css" >
<!--
function Load ()
{
Alert (' Page load ... ');
}
-
</script>
{/literal}
{* contains a PHP statement *}
{PHP}
echo "PHP code Run";
{/php}
{section Name=member loop= $contacts 3 Show=true} {*while loop show is the loop content in show section *}
   {if $smarty. Section.member.first}
  first
{/if}
{if $ Smarty.section.member.last}
  last
{/if}
current loop rownum:{$ Smarty.section.member.rownum}<br/>
   current Loop iteration:{$ Smarty.section.member.iteration}<br/>
   index:{$smarty. Section.member.index} index_ prev:{$contacts 3[member.index_prev]} index_next:{$contacts 3[member.index_next]} index:{$contacts 3[member.index]} member:{$contacts 3[member]}
   {section name=memberchild loop= $contacts 4[member] max=2}
    memberchild:{$contacts 4[member][memberchild]}
   {/section}
   total:{$smarty. section.member.total}{* data length or total number of records *}
  {/section}

</body>
</HTML>

Smarty, smarty format, smarty Integer, Smarty float, smarty various conversions, Smarty date conversion, etc. (RPM)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.