Smarty format the number to int

Source: Internet
Author: User
Tags float number split words uppercase letter
<? Require ("setup. PHP "); define ('pagetitle', 'pagtitle'); function insert_top ($ lid, $ Sid) {echo" insert function ";}$ smarty = new smartyrebuild (); $ smarty-> assign ('name', 'linux '); $ smarty-> assign '); $ smarty-> assign ('English _ word', 'My name X4 is Linux '); $ smarty-> assign ('money', '2017. 2223 '); $ smarty-> assign ('member', array ('fax' => '010-95888484', 'email '=>' [email protected] ', 'Phone '=> array ('hom E '=> '000000', 'mobil' => '000000'); $ tempmember = array (); $ tempmember ['Member '] = 'dsgads '; $ tempmember ["phone"] ["home"] = "444333"; $ contacts = array (); $ contacts [] ["fax"] = "435454 "; $ contacts [] ["phone"] = "223523523"; $ contacts [] ["fax"] = "42532532 "; $ contacts [] ["phone"] = "7888888"; $ contacts2 = array (Array ('fax' => '000000', 'phone' => '000000 '), array ('fax' => '000000', 'phone' => '000000'); $ contacts3 = array (); $ Contacts3 [0] = "23523"; $ contacts4 = array (); $ contacts4 [0] [0] = "23523 "; $ contacts4 [0] [1] = "23523"; $ contacts3 [1] = "23523"; $ contacts4 [1] [0] = "23523 "; $ contacts4 [1] [1] = "23523"; $ contacts3 [2] = "23523"; $ contacts4 [2] [0] = "23523 "; $ contacts4 [2] [1] = "23523"; $ contacts3 [3] = "23523"; $ contacts4 [3] [0] = "23523 "; $ contacts4 [3] [1] = "23523"; $ smarty-> assign ('contacts', $ contacts); $ smarty-> assign ('contacts2 ', $ contacts2); $ smarty-> assign ('Contacts3', $ contacts3); $ smarty-> assign ('contacts4', $ contacts4); $ 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> 

Variable Regulator
The variable regulator is used for variables, user-defined functions, and strings.
You can use the '|' symbol and the regulator name to apply the regulator.
The behavior of a variable regulator is determined by the value of the parameter.
Parameters are separated by the ':' symbol.
If you use the variable regulator to adjust the array variables, the result is that each value of the array is adjusted. If you want the regulator to adjust the entire array, you must add the @ symbol before the regulator name.
Example: {$ articletitle | @ count} (this will be the number in the output $ articletitle array)

Capitalize
Capital the first word of all words in the variable. The parameter value is Boolean to determine whether a word with a number is capitalized. Not capitalized by default

Count_characters
Calculates the number of characters in the variable value. The parameter value Boolean determines whether to calculate the number of spaces. Space is not calculated by default.

Cat
Connect the parameter values in cat to the specified variable. The default value is null.

Count_paragraphs
Calculates the number of paragraphs in a variable.

Count_sentences
Calculates the number of sentences in a variable.

Count_words
Calculate the number of words in a variable

Date_format
Date Format

The first parameter controls the date format.
If the data passed to date_format is empty, the second parameter is used as the default time.

% A-the day of the week

% A-full writing of the day of the week

% B-abbreviated month

% B-full write of the month

% C-Date and Time 06/12/05 11:15:10

% C-century time

% D-number of the month (from 01 to 31)

% D-same as % m/% d/% Y

% E-the number of months. If it is a singular number, add a space (from 1 to 31) to the front)

% G-century

% G-century [century, 9999]

% H-same as % B

% H-24 hours (from 00 to 23)

% I-12 hours (from 01 to 12)

% J-the day of the year (from 001 to 366)

% K-24 hours, with a space in front of a single number (from 0 to 23)

% L-12 hours, with a space in front of a single number. (range 1 to 12)

% M-month (range 01 to 12)

% M-minute

% N-linefeed

% P-display 'am' or 'pm 'in the morning or afternoon'

% R-a.m. Or P. M. Format time

% R-24 hour time

% S-second

% T-Tab

% T-same as % H: % m: % s

% U-[] indicates the day of the week

% U-computing is the week of the year. It starts from the first Sunday of the year.

% V-calculate the week of the year, from 01 to 53. The first week must have at least four days in the year, and Sunday is the first day of the week.

% W-represents the day of the week in the form of a number, and Sunday is 0

% W-the week of the year in the form of digits, starting from the first Monday of the year

% X-display Date: Month/day/year

% X-display time: hour: minute: Second

% Y-not including the Year of the Century

% Y-Year of the Century

% Z-Time Zone

%-Output %

Some of them sometimes cannot be output normally.

Default
Default
Set a default value for null variables.
When the variable is null or unallocated, the output is replaced by the given default value.

Escape
Transcoding
The parameter values are HTML, htmlall, URL, quotes, Hex, hexentity, and JavaScript. The default format is HTML transcoding.

Indent
Indent
In each line of the indent string, the first parameter specifies the number of characters to indent. The default value is 4 characters. The second parameter specifies the characters used to indent the string.

Lower
Lowercase
This is used to lowercase a variable.
Lowercase variable string

Nl2br
Replace line breaks with <br/>

Regex_replace
Regular Expression replacement
Find and replace a regular expression. There must be two parameters. Parameter 1 is to replace a regular expression. Parameter 2 is to replace a text string.

Replace
Replace
A simple search and replacement string must have two parameters. Parameter 1 is the string to be replaced, and parameter 2 is the text to be replaced.

Spacify
Spacify inserts spaces or other strings between each character of a string. The parameter indicates the string to be inserted between two characters. The default value is a space.

String_format string formatting
It is a method for formatting floating-point numbers, such as decimal numbers. It is formatted using the sprintf syntax. Parameters are required, and the format is required. % D indicates an integer, and %. 2f indicates two floating point numbers are truncated.

Strip removal (extra space)
Replace all repeated spaces. line feed and tab are single or specified strings. If there is a parameter, It is the specified string.

Strip_tags remove all HTML tags

Truncate Interception
Parameter 1, specifies the number of characters intercepted. The default value is 80.
The second parameter specifies the characters after the intercepted string. The default value is...
The third parameter determines whether to accurately intercept words. If it is false by default, Smarty does not split words.

Upper converts the variable to uppercase

Wordwrap row width constraint
The first parameter specifies the width of the paragraph (that is, the number of characters in a row, exceeding the number of characters in line). The default value is 80.
The second parameter specifies the characters used at the constraint point (the default is the line break \ n ).
The third parameter determines whether to accurately intercept characters. By default, the characters cannot be separated during intercept.

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.