PHP学习之 PHP 运算符
运算符用于对值进行运算.
PHP 运算符
本部分列出了在 PHP 中使用的各种运算符:
算数运算符
运算符说明例子结果
+
Addition
x=2
x+2
4
-
Subtraction
x=2
5-x
3
*
Multiplication
x=4
x*5
20
/
Division
15/5
5/2
3
2.5
%
Modulus (division remainder)
5%2
10%8
10%2
1
2
0
++
Increment
x=5
x++
x=6
--
Decrement
x=5
x--
x=4
赋值运算符
运算符说明例子
=
x=y
x=y
+=
x+=y
x=x+y
-=
x-=y
x=x-y
*=
x*=y
x=x*y
/=
x/=y
x=x/y
.=
x.=y
x=x.y
%=
x%=y
x=x%y
比较运算符
运算符说明例子
==
is equal to
5==8 returns false
!=
is not equal
5!=8 returns true
>
is greater than
5>8 returns false
<
is less than
5<8 returns true
>=
is greater than or equal to
5>=8 returns false
<=
is less than or equal to
5<=8 returns true
逻辑运算符
运算符说明例子
&&
and
x=6
y=3
(x < 10 && y > 1) returns true
||
or
x=6
y=3
(x==5 || y==5) returns false
!
not
x=6
y=3
!(x==y) returns true
相关文档:
最近有个小东西要查看mssql数据库是用php实现的,以前我用php5.2时感觉挺简单的所以想php5.3也应该很简单的
为什么要用php5.3呢因为我想用sqlite3.0的啊,因为php5.2的不支持sqlite3.0的啊,所以我特意去下了5.3了下载回来了才发现5.3里没有mssql的dll扩展了,郁闷啊,不管这么多先用起那sqlite3.0再说了
sqlite3.0的部分 ......
/*php 防注入函数
string $feifa 限制元素组成
如有非法字符跳转到上一页 返回 0 没有返回 1
*/
//使用方法
//$feifa=array("select","delete","from","update","create","destory","drop","alter" ......
<pre>
PHP代码
<?php
// 例子1
function test_global() {
global $var1, $var2;
$var2 =& $var1;
}
function test_globals() {
......
$str=preg_replace("/\s+/", " ", $str); //过滤多余回车
$str=preg_replace("/<[ ]+/si","<",$str); //过滤<__("<"号后面带空格)
$str=preg_replace("/<\!--.*?-->/si","",$str); //注释
$str=preg_replace("/<(\!.*?)>/si","",$s ......
基本的 PHP 语法
PHP 的脚本块以 <?php 开始,以 ?> 结束。您可以把 PHP 的脚本块放置在文档中的任何位置。
当然,在支持简写的服务器上,您可以使用 <? 和 ?> 来开始和结束脚本块。
不过,为了达到最好的兼容性,我们推荐您使用标准形式 (<?php),而不是简写形式。
<?php
?>
PHP 文件通常会包 ......