1,变量定义及使用:$variable
2,字符串和变量连接:.
3,动态调用函数:
function write($text){} //定义function write()函数
function writeBold($text) {}//定义function write()函数
$myFunction = "write";//定义变量
$myFunction("你好!<BR>");//由于变量后面有括号,所以找名字相同的function函数,调用write()
print("<BR>\n");
$myFunction = "writeBold";//定义变量
$myFunction("再见!");//调用writeBold()
print("<BR>\n");
4,一维数组:
定义:
$Cities[] = "<B>北京</B>";//等同于$Cities[0] = "北京"
$Cities[] = "<B>天津</B>";//等同于$Cities[1] = "天津"
$Cities[] = "<B>上海</B>";//等同于$Cities[2] = "上海"
$Cities[] = "<B>深圳</B>";//等同于$Cities[3] = "深圳"
初始化:
$monthName = array(
/*定义$monthName[1]到$monthName[12]*/
1=>"January", "February", "March",
"April", "May", "June",
"July", "August", "September",
"October", "November", "December",
/*定义$monthName["Jan"]到$monthName["Dec"]*/
"Jan"=>"January", "Feb"=>"February",
"Mar"=>"March", "Apr"=>"April",
"May"=>"May", "Jun"=>"June",
"Jul"=>"July", "Aug"=>"August",
"Sep"=>"September", "Oct"=>"October",
"Nov"=>"November", "Dec"=>"December",
);
5,多维数组:
$Cities = array(//二维数组array()
"华北地区"=>array(
"北京市",
"天津市",
"石家庄"
),
"西北地区"=>array(
"西安",
"拉萨"
)
);
print("华北地区: ".$Cities["华北地区"][0]);//打印$Cities["华北地区"][0]——输出:华北地区:北京
6,引入文件:include("40-2.php");——里面的函数、变量等可以随便使用。
7,获取表单值: $_POST['username']。
8,fgetc (file) —— 从文件指针中读取一个字符。
fgets (file, length) ——读取文件的每一行,length默认为1024字节。
fgetss (file,length,tags) —— 读取文件的每一行,并且过滤标签(php或html),默认过滤所有标签。
9,常用数值判断函数:
数组——is_array($varName);
双精度数——is_double($varName);;
整数——is_integer($varName);
对象——is_object($varName);
字符——is_string($varName);