1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
<?php
class
Cat
{
public
$name
;
public
$age
;
public
$color
;
}
$cat1
=
new
Cat();
//对类进行实例化/创建一个对象/实例化对象 三者说法同种意思
$cat1
->name=
"小白"
;
$cat1
->age=10;
$cat1
->color=
"red"
;
$FindCat
=
"小白"
;
if
(
$cat1
->name==
$FindCat
)
{
ECHO
$FindCat
.
"存在"
;
}
?>
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
<?php
class
Cat
{
public
$name
;
public
$age
;
public
$color
;
}
$c
=90;
$cat1
=
new
Cat();
$cat1
->name=
"小白"
;
$cat1
->age=10;
$cat1
->color=
"red"
;
$cat2
=
$cat1
?>
|
1
2
3
4
5
6
7
|
<?php
$a
=9;
$b
=
$a
;
$b
=
$b
+8;
Echo
$a
.
" "
.
$b
;
?>
|
1
2
3
4
5
6
7
|
<?php
$a
=9;
$b
=&
$a
;
$b
=
$b
+8;
Echo
$a
.
" "
.
$b
;
?>
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
<?php
Class
Person
{
public
$name
;
Public
$age
;
}
$p1
=
new
Person();
$p1
->name=
"小明"
;
$p1
->age=10;
Function
test1(
$p
)
{
$p
->name=
"小花"
;
}
Test1(
$p1
);
Echo
$p1
->name;
?>
|
1
2
3
4
5
6
7
8
9
10
11
12
|
<?php
$arr
=
array
(
$a1
,
$a2
);
$a1
=
array
(1,2,3);
$a2
=
array
(4,5,6,7);
foreach
(
$arr
as
$k
=>
$v
)
{
echo
"$k=$v"
;
}
var_dump(
$arr
);
?>
|
1
2
3
4
5
6
7
8
9
10
|
<?php
$a1
=
array
(1,2,3);
$a2
=
array
(4,5,6,7);
$arr
=
array
(
$a1
,
$a2
);
foreach
(
$arr
as
$k
=>
$v
)
{
echo
"$k=$v"
;
}
var_dump(
$arr
);
?>
|