PHP Entry variable Digital _php tutorial

Source: Internet
Author: User
When introducing variables, I made it clear that PHP has integer and floating point (fractional) numeric types. However, in my experience, both types can be categorized under a general figure (to a great extent).

The following is a list of the variables that are valid in PHP for numeric types:

Note: These values are never enclosed in quotation marks (if you do, they are strings that contain numeric values, there is an example in the connection string example), and you cannot use commas to represent thousands separators (thousand separator example: 20,943).

Two functions commonly used in processing numbers:
Round () is used to round a decimal to the nearest integer, or to round a decimal to a specified number of digits.
Number_format () is used to convert a number to a more common representation, with a comma as the thousand separator, and to set the specified number of digits in the decimal point.

 
  

Interested people can print their own results, but one thing to note, to separate the results, or print the various results will be linked together, this is not a little bit of a small test???

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

Let's do a practical example to:

 
  Single quotation marks 
 
  '. $quantity. '$ '. $price. '$ '. $total. '.

'; ? >

To be able to print out the combination< span="">of HTML, dollar sign, and variable. There is also another way to print (double quotes), which is placed in the PHP entry single quote and double quotation marks.

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

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

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

Let's take a look at the operator knowledge points and numbers related to the bar (I probably see, understand can, in fact, and we learn math when we go to school, understand the algorithm, for interested students can Baidu Google specific usage)

Operator: an operator is a symbol used to perform some sort of operation on an array and a variable.

< p="">

< span="">

< span="">

< span="">

< span="">

< span="">

< span="">

< span="">

< span="">

< span="">

< span="">

< span="">

< span="">

< span="">

< span="">

< span="">

< span="">

< span="">

< span="">

< p="">

< span="">

< span="">

< span="">

< span="">

< span="">

< p="">

< span="">

< span="">

< span="">

< span="">

< span="">

< span="">

< span="">

< span="">

<>

< span="">

<>$b

< span="">

< span="">

<>< span="">

< span="">

$b

<>

< span="">

<>

=

< span="">

= $b

Note: Identity means that only the operands on both sides are equal and the data type is equivalent to return true;

For example: 0==0 "This return is true because the operands are equal;

0=== "0" This return is false because the data type is different.

< p="">

< span="">

< span="">

< span="">

< span="">

< span="">

< span="">

< span="">

< span="">< span="">< span="">< span="">< span="">< span="">

< P class= "P0" >

/span>

< span="">

< span="">

< span="">

< span="">< span="">< span="">< span="">< span="">< span="">< span="">< span="">< span="">< span="">< span="">

< span="">

< span="">

< span="">

< span="">< span="">

< span="">

< span="">

< span="">

< span="">< span="">

Operator< span="">< span="">< span="">< span="">< span="">< span="">< span="">< span="">

5. Ternary operator

Condition? Value if True:value if False

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

6.< span="">:

$a =@ (57/0);

The divisor cannot be< span="">< span="">< span="">< span="">

< p="">

< span="">

< span="">

< span="">

< span="">

< span="">

< span="">

< span="">

< span="">< span="">< span="">< span="">

< span="">

< span="">

< span="">< span="">< span="">< span="">< span="">

< span="">

< span="">

< span="">< span="">< span="">< span="">< span="">

< span="">

< span="">

< span="">< span="">< span="">< span="">< span="">

<>

< span="">

< span="">

< span="">< span="">< span="">< span="">< span="">

< span="">

< span="">

< span="">< span="">< span="">< span="">< span="">

Precedence and associativity of operators:

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

Operators also have associativity, which is the order in which operators of the same precedence are executed. This order is usually left-to-right, right-to-left, or irrelevant.

The table for operator precedence is given below. The topmost operator has the lowest precedence, and is incremented by the top-down order of the table.

< p="">

< span="">

< span="">

< span="">

< span="">

< span="">

< span="">

< span="">

< span="">

< span="">

< span="">

< span="">

< span="">

< span="">

<>>=

< span="">

< span="">

< span="">

< span="">

< span="">

< span="">

< span="">

< span="">

< span="">

< span="">

< span="">

< span="">

< span="">

< span="">

<>>=

< span="">

<>>

< span="">

< span="">

< span="">

< span="">

< span="">

< span="">

< span="">

< span="">

< span="">

< span="">

< span="">

< span="">

To avoid priority confusion, you can use parentheses to avoid precedence.

http://www.bkjia.com/PHPjc/743386.html www.bkjia.com true http://www.bkjia.com/PHPjc/743386.html techarticle when introducing variables, I made it clear that PHP has integer and floating point (fractional) numeric types. However, according to my experience, both types can be categorized under the general numbers (in 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.