Class works without declaring variables?
Posted
by
Maxim Droy
on Stack Overflow
See other posts from Stack Overflow
or by Maxim Droy
Published on 2012-04-06T11:20:07Z
Indexed on
2012/04/06
11:29 UTC
Read the original article
Hit count: 180
I'm learned php as functional and procedure language. Right now try to start learn objective-oriented and got an important question.
I have code:
class car {
function set_car($model) {
$this->model = $model;
}
function check_model()
{
if($this->model == "Mercedes") echo "Good car";
}
}
$mycar = new car;
$mycar->set_car("Mercedes");
echo $mycar->check_model();
Why it does work without declaration of $model?
var $model;
in the begin?
Because in php works "auto-declaration" for any variables? I'm stuck
© Stack Overflow or respective owner