Php entry variable number_php tutorial

Source: Internet
Author: User
Php entry variable number. When introducing variables, I clearly pointed out that PHP has integer and floating point (decimal) numeric types. However, based on my experience, both of these types can be categorized under normal numbers (I explicitly pointed out that PHP has integer and floating point (decimal) types when introducing variables very much) numeric type. However, based on my experience, both types can be categorized under general numbers (to a great extent, this is the case ).

The following lists the valid numeric variables in PHP:

8 3.14 10980843985 -4.2398508 4.4e2 

Note: these values will never be enclosed in quotation marks (if so, they are strings containing values, and there is an example like this in the connection string example ), you cannot use commas (,) to indicate the thousands of separators (for example, 20,943 ).

Two common numeric functions:
Round () is used to round a decimal number to the nearest integer, or to round a decimal number to a specified number of digits.
Number_format () is used to convert a number into a more common representation, using a comma as the thousands separator; you can also set the specified number of decimal places.

 

If you are interested, you can print the results on your own. However, note that you should separate the results. Otherwise, the printed results will be linked together. this is not a small test ???

========================================================== ==========================================================

The following is an example:

 Single quotes 
 What you sell'. $ Quantity .'Product, the unit price is$ '. $ Price .'. Plus the invoice tax, the total amount is$ '. $ Total .'.

';?>

To print the combination of HTML, dollar signs, and variables ,. There is also another printing method (double quotation marks), which is put in the difference between single quotation marks and double quotation marks for php beginners.

Many mathematical operators also have corresponding value assignment operators, which allow short value assignment statements. The following line of statements:

$ Total = $ total + ($ total * $ taxrate); can be rewritten as: $ total + = ($ total * $ taxrate );

========================================================== ============================================

Next, let's take a look at the operator knowledge points related to numbers (just take a look at them and understand them. in fact, it's just like learning mathematics when we went to school to understand the algorithm rules, if you are interested, you can use Baidu Google)

Operator: an operator is a symbol used to perform some operation on arrays and variables.

$ B

$ B

=

= $ B

Note: constant equals indicates that true is returned only when the operands on both sides are equal and the data type is equal;

For example, if the value is 0 = 0, true is returned because the operands are equal;

0 = "0" returns false because of different data types.

Operator

5. ternary operators

Condition? Value if true: value if false

Example: = 50? "Passed": "Failed ")

6 ,:

$ A = @ (57/0 );

The divisor cannot be

Operator priority and associativity:

Generally, operators have a set of priorities, that is, the order in which they are executed.

Operators are also associated, that is, the execution sequence of operators with the same priority. This sequence is usually left-to-right, right-to-left, or unrelated.

The following table lists the operator priorities. The top operator has the lowest priority, and increases the priority according to the table's ascending order.

> =

> =

>

To avoid priority confusion, use parentheses to avoid priority.

Decimal number type. However, based on my experience, both types can be categorized under general numbers (in the pole...

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.