易截截图软件、单文件、免安装、纯绿色、仅160KB

php 基础笔记 logic statements

/***************************by
garcon1986********************************/
<?php
//if 语句
$a = $b = 3;
if($a = $b)
print "a is equal to b<br>";
//else 语句
if($a < $b){
print "a is smaller than b";
} else {
print "a is not smaller than b<br>";
}
//elseif = else if 语句
if($a>$b){
print "a is bigger than b";
}else if($a = $b){
print "a is equal than b";
}else {
print "a is smaller to b<br>";
}
// when you don't use "{}", you can't separate elseif.
//当不用{}时,elseif不能分开
if($a>$b):
print "a>b";
elseif($a==$b):
//else if($a==$b): // this is wrong
print "a=b";
print '<br>';
endif;
//while语句
$i = 0;
while($i<=10){
print $i++.'<br>';
}
$i=15;
while($i<=20):
print $i;
$i++;
endwhile;
print '<br>';
//The difference between 'do while' and 'while' is: 'do while' will execute once at least.
//do while 和while的区别在于前者至少要执行一次
$i=0;
do {
echo $i;
}while($i>0);
echo '<p>';
//do while example 2
do {
if ($i < 5) {
echo "i is not big enough";
break;
}
$i *= 2;
if ($i < 50) {
break;
}
echo "i is ok";
/* process i */
} while (0);
//for(expression1; expression2; expression3) statement语句
//example1
for($i=0;$i<=6;$i++){
print $i;
}
echo '<br>';
//example2
for($i=0; ; $i++){
if($i>10){
break;
}
print $i;
}
echo '<br>';
//example3
for($i=0;;){
print $i;
$i++;
if($i>6){
break;
}
}
echo '<br>';
//example4
$i=0;
for(;;){
if($i>6){
break;
}
print $i;
$i++;
}
echo '<br>';
//example5
for($i=0;$i<=10;print $i, $i++);
echo '<p>';
//foreach语句
//example1
$arr = array('s','j','g','w','l');
foreach($arr as $value){
echo "$value<br>"; //$value is user-defined.
}
unset($value);
//list to replace foreach, same result
//使


相关文档:

尝试用Gearman实现分布式处理(PHP)

本文需要你已对Gearman有个大致了解,如果不知该东东是何物,请参考之前一篇转帖日志《Gearman - 分布式远程过程处理框架》
顺便再推荐两篇参考文章
http://hi.baidu.com/thinkinginlamp/blog/item/ff49972b9e7378f3e6cd40aa.html
(学学Gearman)
http://www.ibm.com/developerworks/cn/opensource/os-php-gearman/ind ......

PHP程序员最易犯10种错误


1.不转意html entities
一个基本的常识:所有不可信任的输入(特别是用户从form中提交的数据) ,输出之前都要转意。
echo $_GET['usename'] ;
这个例子有可能输出:
<scrīpt>/*更改admin密码的脚本或设置cookie的脚本*/</scrīpt>
这是一个明显的安全隐患,除非你保证你的用户都正确的输入。 ......

flex 和php 通信

php:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">  
<html xmlns="http://www.w3.org/1999/xhtml">  
<head>  
<meta http-equiv="Content-Type" content="text/html; charse ......

PHP常用函数(1)

原文链接:http://www.phpdo.net/index.php/2010/02/11/1-14/
PHP中获得日期时间信息的函数——Getdate
时间戳:包含了从unix新纪元(1970年1月1 日零时)到给定时间的秒数,是一个长整数。
Getdate函数就是用来获得当前时间,或者用来分析时间戳的具体意义。语法:
Array getdate([int timestamp])
含义:ti ......

PHP分页程序源码

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>PHP分页</tit ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号