?php
class
Point2D
{
var
$x
,
$y
;
var
$nom
;
function
Point2D($x
,
$y
)
{
$this
-
x
=
$x
;
$this
-
y
=
$y
;
}
function
donne_nom($nom
)
{
$this
-
nom
=
$nom
;
}
function
LitPoint(
)
{
return
array("x
"
-
$this
-
x
,
"y
"
-
$this
-
y
,
"nom
"
-
$this
-
nom)
;
}
}
$p1
=
new
Point2D(1.233
,
3.445)
;
print_r(get_object_vars($p1))
;
/
/
"$nom
"
est
déclaré
,
mais
non
défini
/
/
Array
/
/
(
/
/
[x
]
-
1.233
/
/
[y
]
-
3.445
/
/
)
$p1
-
setnom("point
#1")
;
print_r(get_object_vars($p1))
;
/
/
Array
/
/
(
/
/
[x
]
-
1.233
/
/
[y
]
-
3.445
/
/
[nom
]
-
point
#1
/
/
)
?
|