选择显示字体大小

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>
&#36;a < &#36;b less than?/font>   true if &#36;a is strictly less than &#36;b.?/font>
&#36;a > &#36;b greater than?/font>   true if &#36;a is strictly greater than &#36;b.?/font>
&#36;a <= &#36;b less than or equal to?/font>  true if &#36;a is less than or equal to &#36;b.?/font>
&#36;a >= &#36;b greater than or equal to?/font>  true if &#36;a is greater than or equal to &#36;b.


 


关键字 本文所属关键字

相关 与本文相关文章

分类 所有文章关键字导航

源码编程相关

Java   Asp   PHP   .Net   XML   C/C++   CGI   VB   Jsp   J2ee   J2se   J2me   EJB   Servlet   Tomcat   Resin   Struts   Weblogic   Eclipse   ANT   GUI   JMS   Web servise   IDEA   Webphere   Hibernate   Spring   Jboss   Applet   Swing   Socket   Javamail   Perl   Ajax   P2P   安全   模式   框架   测试   开源   游戏

SQL数据库相关

My-SQL   Ms-SQL   Access   DB2   Oracle   Sybase   SQLserver   索引   存储过程   加密   数据库   分页   视图  

手机无线相关

3G   Wap   CDMA   GRPS   GSM   IVR   彩信   短信   无线   增值业务

网页设计制作相关

HTML   CSS   网页配色   网页特效   Javascript   VBscript   Dreamweaver   Frontpage   JS   Web   网站设计

网站建设推广相关

建站经验   网站优化   网站排名   推广   Alexa

操作系统/服务器相关

Windows XP   Windows 2000   Windows 2003   Windows Me   Windows 9.x   Linux   UNIX   注册表   操作系统   服务器   应用服务器

图形图像多媒体相关

Photoshop   Fireworks   Flash   Coreldraw   Illustrator   Freehand   Photoimpact   多媒体   图形图像

标准 网站致力的规范

Valid CSS!

无不良内容,无不良广告,无恶意代码

Valid XHTML 1.0 Transitional

creativecommons