search
Homephp教程php手册PHP3中文文档(续5)

中文

算术操作符

    这些工作和基本的学校里教的内容相似。

 

    Table 7-1. Arithmetic Operators(表7-1算术操作符)

example name result
$a + $b Addition Sum of $a and $b.?/FONT>
$a - $b Subtraction Remainder of $b subtracted from $a.?/FONT>
$a * $b Multiplication Product of $a and $b.?/FONT>
$a / $b Division Dividend of $a and $b.?/FONT>
$a % $b Modulus Remainder of $a divided by $b.

 

    其中,除法操作符“/”返回一个整数值(整数除法的结果)如果两个操作数是整数(或者是被转化成整数的字符串)的话。如果任意一个操作数是浮点数,那么将进行浮点运算。

字符串操作符

这个地方仅仅有一个真正的字符串操作符:串联符号“.”。

 

$a = "Hello ";$b = $a . "World!";

// now $b = "Hello World!"

赋值操作符

    基本的赋值操作符就是“=”。您往往会倾向于认为它的含义就是“等于”。不要这样想,它真正的含义就是左侧的操作数获得右侧表达式的值。

 

    一个赋值表达式的意义在于值的指派。也就是说,“$a=3”的值是3。这就允许您做这样的事情:

 

$a = ($b = 4) + 5;

// $a is equal to 9 now, and $b has been set to 4.

 

    作为赋值操作符的一个补充,还有一个针对二进制数和字符传进行操作的组合操作符,该操作符允许您在赋值方采用被赋值表达式的值。例如:

 

$a = 3;

$a += 5; // sets $a to 8, as if we had said: $a = $a + 5;

$b = "Hello ";

$b .= "There!"; // sets $b to "Hello There!", just like $b = $b . "There!";

位操作符

    位操作符允许您精细的操作数据的每一个位。

 

    Table 7-2. Bitwise Operators(表7-2位操作符)

example     name                  result
$a & $b    And    Bits that are set in both $a and $b are set.?/FONT>
$a | $b    Or     Bits that are set in either $a or $b are set.?/FONT>
~ $a?/FONT> Not   Bits that are set in $a are not set, and vice versa.

逻辑操作符

    Table 7-3. Logical Operators(表7-3 逻辑操作符)

 

example      name                    result?/FONT>
$a and $b    And          True of both $a and $b are true.?/FONT>
$a or $b     Or?/FONT>    True if either $a or $b is true.?/FONT>
$a xor $b    Or?/FONT>    True if either $a or $b is true, but not both.?/FONT>
! $a        Not?/FONT>    True if $a is not true.?/FONT>
$a && $b    And?/FONT>    True of both $a and $b are true.?/FONT>
$a || $b    Or?/FONT>     True if either $a or $b is true.

比较操作符

    比较操作符,正如它的名字所示,允许您比较两个值。

 

    Table 7-4. Comparson Operators(表7-4 比较操作符)

example          name       result?/FONT>
$a == $b Equal?/FONT>  True if $a is equal to $b.?/FONT>
$a != $b Not equal    True if $a is not equal to $b.?/FONT>
$a    True if $a is strictly less than $b.?/FONT>
$a > $b Greater than?/FONT>   True if $a is strictly greater than $b.?/FONT>
$a   True if $a is less than or equal to $b.?/FONT>
$a >= $b Greater than or equal to?/FONT>  True if $a is greater than or equal to $b.




Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment

mPDF

mPDF

mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),