background image

$arr_family[] = 

'Peter'

;

哈希表形式数组初始化:
方式一:
$arr_family[

'mother'

] = 

'LinNa'

;

$arr_family[

'father'

] = 

'Jhon'

;

$arr_family[

'mother'

] = 

'Peter'

;

方式二:
$arr_family=

array

(

'mother'

=>

'LinNa'

,

'father'

=>

'Jhon'

,

'son'

=>

'Peter'

);

9.对象:
类:
Class 类名
{

Public $属性名;
Public function 函数名()
{

$变量名;

}

}

<?php

class 

foo{

public 

$C_foo

 = 

'This is a class'

;

public function 

do_foo()

{

echo 

'Doing foo'

;

}

}
  $newfoo = 

new 

foo();

  

print 

$newfoo->

C_foo

;

  

print 

"<br/>"

;

  $newfoo->do_foo();

?>
效果如下:

10.NULL
空,可以使

null,也可以使 NULL,不区分大小写

NULL 表示没有值的变量。
11.数据类型转换
一般情况下,数据类型会自动转换,同时我们也可以进行强制类型转换,强制类型转换的方法是
把数据类型用括号括起来放在要转换的数据类型前面即可。
(int)/(integer) 转换为整形值
(real),(double),(float)转换为双精度
(string)转换为字符串
(array)转换为数组
(object)转换为对象。
12.变量不需要定义就可以使用。
在函数外部定义的变量时全局变量,在函数内部定义或使用的变量是局部变量。